Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard ID filter does not work on models #39940

Closed
kamilmielnik opened this issue Mar 11, 2024 · 1 comment · Fixed by #39963
Closed

Dashboard ID filter does not work on models #39940

kamilmielnik opened this issue Mar 11, 2024 · 1 comment · Fixed by #39963
Assignees
Labels
.Backend Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. Reporting/Dashboards .Team/QueryProcessor :hammer_and_wrench: Type:Bug Product defects
Milestone

Comments

@kamilmielnik
Copy link
Contributor

kamilmielnik commented Mar 11, 2024

Describe the bug

2024-03-11.20-44-46.mp4

To Reproduce

  1. Create a new model based on Orders table, run it and save it
  2. Create a new dashboard
  3. Add the new model to the dashboard
  4. Add an ID filter and connect it to model's ID column
  5. Provide a default value for the filter
  6. Save the dashboard

Expected behavior

Chart is rendered correctly (table with 1 row)

Logs

Response from POST `/api/dashboard/:id/dashcard/:id/card/:id/query`:
{
    "database_id": 1,
    "started_at": "2024-03-11T20:41:02.220010417+07:00",
    "via": [
        {
            "status": "failed",
            "class": "class clojure.lang.ExceptionInfo",
            "error": "Error compiling query: Cannot determine the source table or query for Field clause [:field \"ID\" {:base-type :type/BigInteger}]",
            "stacktrace": [
                "--> query_processor.compile$fn__89980$_AMPERSAND_f__89981$fn__89982.invoke(compile.clj:24)",
                "query_processor.setup$fn__89934$_AMPERSAND_f__89935.invoke(setup.clj:204)",
                "query_processor.setup$fn__89934$fn__89939.invoke(setup.clj:195)",
                "query_processor.compile$fn__89980$_AMPERSAND_f__89981.invoke(compile.clj:20)",
                "query_processor.compile$fn__89980$fn__89985.invoke(compile.clj:16)",
                "query_processor$process_query_STAR__STAR_.invokeStatic(query_processor.clj:45)",
                "query_processor$process_query_STAR__STAR_.invoke(query_processor.clj:43)",
                "query_processor.middleware.enterprise$eval85326$handle_audit_app_internal_queries__85327$fn__85329.invoke(enterprise.clj:96)",
                "query_processor.middleware.enterprise$handle_audit_app_internal_queries_middleware$fn__85337.invoke(enterprise.clj:103)",
                "query_processor.middleware.process_userland_query$fn__90631$_AMPERSAND_f__90632$_AMPERSAND_f__90633.invoke(process_userland_query.clj:165)",
                "query_processor.middleware.process_userland_query$fn__90631$_AMPERSAND_f__90632$fn__90639.invoke(process_userland_query.clj:155)",
                "query_processor.middleware.catch_exceptions$fn__90461$_AMPERSAND_f__90462$_AMPERSAND_f__90463.invoke(catch_exceptions.clj:128)",
                "query_processor.middleware.catch_exceptions$fn__90461$_AMPERSAND_f__90462$fn__90474.invoke(catch_exceptions.clj:118)",
                "query_processor$fn__91270$_AMPERSAND_f__91271$fn__91272.invoke(query_processor.clj:78)",
                "query_processor.setup$fn__89926$_AMPERSAND_f__89927$fn__89928.invoke(setup.clj:168)",
                "query_processor.setup$fn__89916$_AMPERSAND_f__89917$fn__89918.invoke(setup.clj:160)",
                "query_processor.setup$fn__89906$_AMPERSAND_f__89907$fn__89908$fn__89909.invoke(setup.clj:145)",
                "driver$do_with_driver.invokeStatic(driver.clj:97)",
                "driver$do_with_driver.invoke(driver.clj:92)",
                "query_processor.setup$fn__89906$_AMPERSAND_f__89907$fn__89908.invoke(setup.clj:144)",
                "query_processor.setup$fn__89894$_AMPERSAND_f__89895$fn__89896$fn__89899.invoke(setup.clj:131)",
                "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:171)",
                "query_processor.store$do_with_metadata_provider.invoke(store.clj:152)",
                "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:160)",
                "query_processor.store$do_with_metadata_provider.invoke(store.clj:152)",
                "query_processor.setup$fn__89894$_AMPERSAND_f__89895$fn__89896.invoke(setup.clj:130)",
                "query_processor.setup$fn__89876$_AMPERSAND_f__89877$_AMPERSAND_f__89878.invoke(setup.clj:108)",
                "query_processor.setup$fn__89876$_AMPERSAND_f__89877$fn__89881.invoke(setup.clj:102)",
                "query_processor.setup$fn__89934$_AMPERSAND_f__89935.invoke(setup.clj:211)",
                "query_processor.setup$fn__89934$fn__89939.invoke(setup.clj:195)",
                "query_processor$fn__91270$_AMPERSAND_f__91271.invoke(query_processor.clj:76)",
                "query_processor$fn__91270$fn__91276.invoke(query_processor.clj:69)",
                "query_processor.card$fn__113750$_AMPERSAND_f__113751.invoke(card.clj:190)",
                "query_processor.card$fn__113750$fn__113753.invoke(card.clj:186)",
                "query_processor.card$process_query_for_card_default_run_fn$fn__113756$fn__113757.invoke(card.clj:197)",
                "query_processor.streaming$_streaming_response$fn__92758$fn__92759$fn__92760.invoke(streaming.clj:171)",
                "query_processor.streaming$_streaming_response$fn__92758$fn__92759.invoke(streaming.clj:170)",
                "query_processor.streaming$do_with_streaming_rff.invokeStatic(streaming.clj:161)",
                "query_processor.streaming$do_with_streaming_rff.invoke(streaming.clj:148)",
                "query_processor.streaming$_streaming_response$fn__92758.invoke(streaming.clj:167)",
                "async.streaming_response$do_f_STAR_.invokeStatic(streaming_response.clj:69)",
                "async.streaming_response$do_f_STAR_.invoke(streaming_response.clj:67)",
                "async.streaming_response$do_f_async$task__44603.invoke(streaming_response.clj:88)"
            ],
            "error_type": "driver",
            "ex-data": {
                "query": {
                    "constraints": {
                        "max-results": 10000,
                        "max-results-bare-rows": 2000
                    },
                    "type": "query",
                    "metabase.query-processor.middleware.add-dimension-projections/external-remaps": [
                        {
                            "id": 2,
                            "name": "User ID",
                            "field-id": 40,
                            "field-name": "USER_ID",
                            "human-readable-field-id": 16,
                            "human-readable-field-name": "NAME"
                        }
                    ],
                    "middleware": {
                        "js-int-to-string?": true,
                        "ignore-cached-results?": false,
                        "userland-query?": true
                    },
                    "user-parameters": [
                        {
                            "value": [
                                "5"
                            ],
                            "type": "id",
                            "id": "9d8185bc",
                            "target": [
                                "dimension",
                                [
                                    "field",
                                    "ID",
                                    {
                                        "base-type": "type/BigInteger"
                                    }
                                ]
                            ]
                        }
                    ],
                    "viz-settings": {},
                    "info": {
                        "executed-by": 1,
                        "context": "dashboard",
                        "card-id": 116,
                        "card-name": "Orders M1",
                        "dashboard-id": 8,
                        "visualization-settings": {
                            "table.cell_column": "SUBTOTAL"
                        },
                        "metadata/model-metadata": [
                            {
                                "description": "This is a unique ID for the product. It is also called the “Invoice number” or “Confirmation number” in customer facing emails and screens.",
                                "semantic_type": "type/PK",
                                "name": "ID",
                                "field_ref": [
                                    "field",
                                    34,
                                    null
                                ],
                                "effective_type": "type/BigInteger",
                                "id": 34,
                                "visibility_type": "normal",
                                "display_name": "ID",
                                "base_type": "type/BigInteger"
                            },
                            {
                                "description": "The id of the user who made this order. Note that in some cases where an order was created on behalf of a customer who phoned the order in, this might be the employee who handled the request.",
                                "semantic_type": "type/FK",
                                "name": "USER_ID",
                                "fk_target_field_id": 15,
                                "field_ref": [
                                    "field",
                                    40,
                                    null
                                ],
                                "effective_type": "type/Integer",
                                "id": 40,
                                "visibility_type": "normal",
                                "display_name": "User ID",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 929,
                                        "nil%": 0.0
                                    }
                                },
                                "base_type": "type/Integer"
                            },
                            {
                                "description": "The product ID. This is an internal identifier for the product, NOT the SKU.",
                                "semantic_type": "type/FK",
                                "name": "PRODUCT_ID",
                                "fk_target_field_id": 68,
                                "field_ref": [
                                    "field",
                                    37,
                                    null
                                ],
                                "effective_type": "type/Integer",
                                "id": 37,
                                "visibility_type": "normal",
                                "display_name": "Product ID",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 200,
                                        "nil%": 0.0
                                    }
                                },
                                "base_type": "type/Integer"
                            },
                            {
                                "description": "The raw, pre-tax cost of the order. Note that this might be different in the future from the product price due to promotions, credits, etc.",
                                "name": "SUBTOTAL",
                                "field_ref": [
                                    "field",
                                    41,
                                    null
                                ],
                                "effective_type": "type/Float",
                                "id": 41,
                                "visibility_type": "normal",
                                "display_name": "Subtotal",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 340,
                                        "nil%": 0.0
                                    },
                                    "type": {
                                        "type/Number": {
                                            "min": 15.691943673970439,
                                            "q1": 49.74894519060184,
                                            "q3": 105.42965746993103,
                                            "max": 148.22900526552291,
                                            "sd": 32.53705013056317,
                                            "avg": 77.01295465356547
                                        }
                                    }
                                },
                                "base_type": "type/Float"
                            },
                            {
                                "description": "This is the amount of local and federal taxes that are collected on the purchase. Note that other governmental fees on some products are not included here, but instead are accounted for in the subtotal.",
                                "name": "TAX",
                                "field_ref": [
                                    "field",
                                    35,
                                    null
                                ],
                                "effective_type": "type/Float",
                                "id": 35,
                                "visibility_type": "normal",
                                "display_name": "Tax",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 797,
                                        "nil%": 0.0
                                    },
                                    "type": {
                                        "type/Number": {
                                            "min": 0.0,
                                            "q1": 2.273340386603857,
                                            "q3": 5.337275338216307,
                                            "max": 11.12,
                                            "sd": 2.3206651358900316,
                                            "avg": 3.8722100000000004
                                        }
                                    }
                                },
                                "base_type": "type/Float"
                            },
                            {
                                "description": "The total billed amount.",
                                "name": "TOTAL",
                                "field_ref": [
                                    "field",
                                    39,
                                    null
                                ],
                                "effective_type": "type/Float",
                                "id": 39,
                                "visibility_type": "normal",
                                "display_name": "Total",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 4426,
                                        "nil%": 0.0
                                    },
                                    "type": {
                                        "type/Number": {
                                            "min": 8.93914247937167,
                                            "q1": 51.34535490743823,
                                            "q3": 110.29428389265787,
                                            "max": 159.34900526552292,
                                            "sd": 34.26469575709948,
                                            "avg": 80.35871658771228
                                        }
                                    }
                                },
                                "base_type": "type/Float"
                            },
                            {
                                "description": "Discount amount.",
                                "semantic_type": "type/Discount",
                                "name": "DISCOUNT",
                                "field_ref": [
                                    "field",
                                    33,
                                    null
                                ],
                                "effective_type": "type/Float",
                                "id": 33,
                                "visibility_type": "normal",
                                "display_name": "Discount with a very long name",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 701,
                                        "nil%": 0.898
                                    },
                                    "type": {
                                        "type/Number": {
                                            "min": 0.17088996672584322,
                                            "q1": 2.9786226681458743,
                                            "q3": 7.338187788658235,
                                            "max": 61.69684269960571,
                                            "sd": 3.053663125001991,
                                            "avg": 5.161255547580326
                                        }
                                    }
                                },
                                "base_type": "type/Float"
                            },
                            {
                                "description": "The date and time an order was submitted.",
                                "semantic_type": "type/CreationTimestamp",
                                "unit": "default",
                                "name": "CREATED_AT",
                                "field_ref": [
                                    "field",
                                    38,
                                    {
                                        "temporal-unit": "default"
                                    }
                                ],
                                "effective_type": "type/DateTime",
                                "id": 38,
                                "visibility_type": "normal",
                                "display_name": "Created At",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 10001,
                                        "nil%": 0.0
                                    },
                                    "type": {
                                        "type/DateTime": {
                                            "earliest": "2022-04-30T18:56:13.352Z",
                                            "latest": "2026-04-19T14:07:15.657Z"
                                        }
                                    }
                                },
                                "base_type": "type/DateTime"
                            },
                            {
                                "description": "Number of products bought.",
                                "semantic_type": "type/Quantity",
                                "name": "QUANTITY",
                                "field_ref": [
                                    "field",
                                    36,
                                    null
                                ],
                                "effective_type": "type/Integer",
                                "id": 36,
                                "visibility_type": "normal",
                                "display_name": "Quantity",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 62,
                                        "nil%": 0.0
                                    },
                                    "type": {
                                        "type/Number": {
                                            "min": 0.0,
                                            "q1": 1.755882607764982,
                                            "q3": 4.882654507928044,
                                            "max": 100.0,
                                            "sd": 4.214258386403798,
                                            "avg": 3.7015
                                        }
                                    }
                                },
                                "base_type": "type/Integer"
                            },
                            {
                                "description": "The name of the user who owns an account",
                                "semantic_type": "type/Name",
                                "name": "NAME",
                                "field_ref": [
                                    "field",
                                    16,
                                    {
                                        "source-field": 40
                                    }
                                ],
                                "effective_type": "type/Text",
                                "id": 16,
                                "visibility_type": "normal",
                                "display_name": "User ID",
                                "fingerprint": {
                                    "global": {
                                        "distinct-count": 2499,
                                        "nil%": 0.0
                                    },
                                    "type": {
                                        "type/Text": {
                                            "percent-json": 0.0,
                                            "percent-url": 0.0,
                                            "percent-email": 0.0,
                                            "percent-state": 0.0,
                                            "average-length": 13.532
                                        }
                                    }
                                },
                                "base_type": "type/Text"
                            }
                        ],
                        "query-hash": "0x086643BA"
                    },
                    "database": 1,
                    "query": {
                        "source-table": 5,
                        "filter": [
                            "=",
                            [
                                "field",
                                "ID",
                                {
                                    "base-type": "type/BigInteger"
                                }
                            ],
                            [
                                "value",
                                5,
                                {
                                    "base_type": "type/BigInteger"
                                }
                            ]
                        ],
                        "fields": [
                            [
                                "field",
                                34,
                                null
                            ],
                            [
                                "field",
                                40,
                                {
                                    "metabase.query-processor.middleware.add-dimension-projections/original-field-dimension-id": 2
                                }
                            ],
                            [
                                "field",
                                37,
                                null
                            ],
                            [
                                "field",
                                41,
                                null
                            ],
                            [
                                "field",
                                35,
                                null
                            ],
                            [
                                "field",
                                39,
                                null
                            ],
                            [
                                "field",
                                33,
                                null
                            ],
                            [
                                "field",
                                38,
                                {
                                    "temporal-unit": "default"
                                }
                            ],
                            [
                                "field",
                                36,
                                null
                            ],
                            [
                                "field",
                                16,
                                {
                                    "source-field": 40,
                                    "metabase.query-processor.middleware.add-dimension-projections/new-field-dimension-id": 2,
                                    "join-alias": "PEOPLE__via__USER_ID"
                                }
                            ]
                        ],
                        "joins": [
                            {
                                "alias": "PEOPLE__via__USER_ID",
                                "strategy": "left-join",
                                "source-table": 3,
                                "condition": [
                                    "=",
                                    [
                                        "field",
                                        40,
                                        null
                                    ],
                                    [
                                        "field",
                                        15,
                                        {
                                            "join-alias": "PEOPLE__via__USER_ID"
                                        }
                                    ]
                                ],
                                "fk-field-id": 40
                            }
                        ],
                        "limit": 2000,
                        "metabase.query-processor.middleware.limit/original-limit": null
                    }
                },
                "type": "driver"
            }
        }
    ],
    "action_id": null,
    "error_type": "invalid-query",
    "json_query": {
        "constraints": {
            "max-results": 10000,
            "max-results-bare-rows": 2000
        },
        "type": "query",
        "middleware": {
            "js-int-to-string?": true,
            "ignore-cached-results?": false,
            "userland-query?": true
        },
        "viz-settings": {},
        "database": 1,
        "query": {
            "source-table": 5
        },
        "parameters": [
            {
                "type": "id",
                "value": [
                    "5"
                ],
                "id": "9d8185bc",
                "target": [
                    "dimension",
                    [
                        "field",
                        "ID",
                        {
                            "base-type": "type/BigInteger"
                        }
                    ]
                ]
            }
        ],
        "cache-ttl": null
    },
    "native": null,
    "status": "failed",
    "class": "class clojure.lang.ExceptionInfo",
    "stacktrace": [
        "--> query_processor.util.add_alias_info$fn__85902$_AMPERSAND_f__85905.invoke(add_alias_info.clj:193)",
        "query_processor.util.add_alias_info$fn__85902$fn__85913.invoke(add_alias_info.clj:180)",
        "query_processor.util.add_alias_info$eval86071$fn__86072.invoke(add_alias_info.clj:392)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_$replace_86113__86114$fn__86121$fn__86122.invoke(add_alias_info.clj:447)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_$replace_86113__86114$fn__86121.invoke(add_alias_info.clj:447)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_$replace_86113__86114.invoke(add_alias_info.clj:447)",
        "mbql.util.match.impl$replace_in_collection.invokeStatic(impl.cljc:48)",
        "mbql.util.match.impl$replace_in_collection.invoke(impl.cljc:39)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_$replace_86113__86114$fn__86121.invoke(add_alias_info.clj:447)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_$replace_86113__86114.invoke(add_alias_info.clj:447)",
        "mbql.util.match.impl$replace_in_collection$iter__30539__30543$fn__30544.invoke(impl.cljc:45)",
        "mbql.util.match.impl$replace_in_collection.invokeStatic(impl.cljc:44)",
        "mbql.util.match.impl$replace_in_collection.invoke(impl.cljc:39)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_$replace_86113__86114$fn__86121.invoke(add_alias_info.clj:447)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_$replace_86113__86114.invoke(add_alias_info.clj:447)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_.invokeStatic(add_alias_info.clj:447)",
        "query_processor.util.add_alias_info$add_alias_info_STAR_.invoke(add_alias_info.clj:444)",
        "query_processor.util.add_alias_info$add_alias_info$fn__86131.invoke(add_alias_info.clj:491)",
        "query_processor.util.add_alias_info$add_alias_info.invokeStatic(add_alias_info.clj:486)",
        "query_processor.util.add_alias_info$add_alias_info.invoke(add_alias_info.clj:457)",
        "driver.sql.query_processor$eval87570$fn__87571.invoke(query_processor.clj:1454)",
        "driver.sql.query_processor$mbql__GT_honeysql.invokeStatic(query_processor.clj:1460)",
        "driver.sql.query_processor$mbql__GT_honeysql.invoke(query_processor.clj:1456)",
        "driver.sql.query_processor$mbql__GT_native.invokeStatic(query_processor.clj:1471)",
        "driver.sql.query_processor$mbql__GT_native.invoke(query_processor.clj:1467)",
        "driver.sql$eval103130$fn__103131.invoke(sql.clj:49)",
        "query_processor.compile$compile_STAR_.invokeStatic(compile.clj:14)",
        "query_processor.compile$compile_STAR_.invoke(compile.clj:11)",
        "query_processor.compile$fn__89980$_AMPERSAND_f__89981$fn__89982.invoke(compile.clj:22)",
        "query_processor.setup$fn__89934$_AMPERSAND_f__89935.invoke(setup.clj:204)",
        "query_processor.setup$fn__89934$fn__89939.invoke(setup.clj:195)",
        "query_processor.compile$fn__89980$_AMPERSAND_f__89981.invoke(compile.clj:20)",
        "query_processor.compile$fn__89980$fn__89985.invoke(compile.clj:16)",
        "query_processor$process_query_STAR__STAR_.invokeStatic(query_processor.clj:45)",
        "query_processor$process_query_STAR__STAR_.invoke(query_processor.clj:43)",
        "query_processor.middleware.enterprise$eval85326$handle_audit_app_internal_queries__85327$fn__85329.invoke(enterprise.clj:96)",
        "query_processor.middleware.enterprise$handle_audit_app_internal_queries_middleware$fn__85337.invoke(enterprise.clj:103)",
        "query_processor.middleware.process_userland_query$fn__90631$_AMPERSAND_f__90632$_AMPERSAND_f__90633.invoke(process_userland_query.clj:165)",
        "query_processor.middleware.process_userland_query$fn__90631$_AMPERSAND_f__90632$fn__90639.invoke(process_userland_query.clj:155)",
        "query_processor.middleware.catch_exceptions$fn__90461$_AMPERSAND_f__90462$_AMPERSAND_f__90463.invoke(catch_exceptions.clj:128)",
        "query_processor.middleware.catch_exceptions$fn__90461$_AMPERSAND_f__90462$fn__90474.invoke(catch_exceptions.clj:118)",
        "query_processor$fn__91270$_AMPERSAND_f__91271$fn__91272.invoke(query_processor.clj:78)",
        "query_processor.setup$fn__89926$_AMPERSAND_f__89927$fn__89928.invoke(setup.clj:168)",
        "query_processor.setup$fn__89916$_AMPERSAND_f__89917$fn__89918.invoke(setup.clj:160)",
        "query_processor.setup$fn__89906$_AMPERSAND_f__89907$fn__89908$fn__89909.invoke(setup.clj:145)",
        "driver$do_with_driver.invokeStatic(driver.clj:97)",
        "driver$do_with_driver.invoke(driver.clj:92)",
        "query_processor.setup$fn__89906$_AMPERSAND_f__89907$fn__89908.invoke(setup.clj:144)",
        "query_processor.setup$fn__89894$_AMPERSAND_f__89895$fn__89896$fn__89899.invoke(setup.clj:131)",
        "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:171)",
        "query_processor.store$do_with_metadata_provider.invoke(store.clj:152)",
        "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:160)",
        "query_processor.store$do_with_metadata_provider.invoke(store.clj:152)",
        "query_processor.setup$fn__89894$_AMPERSAND_f__89895$fn__89896.invoke(setup.clj:130)",
        "query_processor.setup$fn__89876$_AMPERSAND_f__89877$_AMPERSAND_f__89878.invoke(setup.clj:108)",
        "query_processor.setup$fn__89876$_AMPERSAND_f__89877$fn__89881.invoke(setup.clj:102)",
        "query_processor.setup$fn__89934$_AMPERSAND_f__89935.invoke(setup.clj:211)",
        "query_processor.setup$fn__89934$fn__89939.invoke(setup.clj:195)",
        "query_processor$fn__91270$_AMPERSAND_f__91271.invoke(query_processor.clj:76)",
        "query_processor$fn__91270$fn__91276.invoke(query_processor.clj:69)",
        "query_processor.card$fn__113750$_AMPERSAND_f__113751.invoke(card.clj:190)",
        "query_processor.card$fn__113750$fn__113753.invoke(card.clj:186)",
        "query_processor.card$process_query_for_card_default_run_fn$fn__113756$fn__113757.invoke(card.clj:197)",
        "query_processor.streaming$_streaming_response$fn__92758$fn__92759$fn__92760.invoke(streaming.clj:171)",
        "query_processor.streaming$_streaming_response$fn__92758$fn__92759.invoke(streaming.clj:170)",
        "query_processor.streaming$do_with_streaming_rff.invokeStatic(streaming.clj:161)",
        "query_processor.streaming$do_with_streaming_rff.invoke(streaming.clj:148)",
        "query_processor.streaming$_streaming_response$fn__92758.invoke(streaming.clj:167)",
        "async.streaming_response$do_f_STAR_.invokeStatic(streaming_response.clj:69)",
        "async.streaming_response$do_f_STAR_.invoke(streaming_response.clj:67)",
        "async.streaming_response$do_f_async$task__44603.invoke(streaming_response.clj:88)"
    ],
    "card_id": 116,
    "context": "dashboard",
    "error": "Cannot determine the source table or query for Field clause [:field \"ID\" {:base-type :type/BigInteger}]",
    "row_count": 0,
    "running_time": 0,
    "preprocessed": {
        "constraints": {
            "max-results": 10000,
            "max-results-bare-rows": 2000
        },
        "type": "query",
        "metabase.query-processor.middleware.add-dimension-projections/external-remaps": [
            {
                "id": 2,
                "name": "User ID",
                "field-id": 40,
                "field-name": "USER_ID",
                "human-readable-field-id": 16,
                "human-readable-field-name": "NAME"
            }
        ],
        "middleware": {
            "js-int-to-string?": true,
            "ignore-cached-results?": false,
            "userland-query?": true
        },
        "user-parameters": [
            {
                "value": [
                    "5"
                ],
                "type": "id",
                "id": "9d8185bc",
                "target": [
                    "dimension",
                    [
                        "field",
                        "ID",
                        {
                            "base-type": "type/BigInteger"
                        }
                    ]
                ]
            }
        ],
        "viz-settings": {},
        "info": {
            "executed-by": 1,
            "context": "dashboard",
            "card-id": 116,
            "card-name": "Orders M1",
            "dashboard-id": 8,
            "visualization-settings": {
                "table.cell_column": "SUBTOTAL"
            },
            "metadata/model-metadata": [
                {
                    "description": "This is a unique ID for the product. It is also called the “Invoice number” or “Confirmation number” in customer facing emails and screens.",
                    "semantic_type": "type/PK",
                    "name": "ID",
                    "field_ref": [
                        "field",
                        34,
                        null
                    ],
                    "effective_type": "type/BigInteger",
                    "id": 34,
                    "visibility_type": "normal",
                    "display_name": "ID",
                    "base_type": "type/BigInteger"
                },
                {
                    "description": "The id of the user who made this order. Note that in some cases where an order was created on behalf of a customer who phoned the order in, this might be the employee who handled the request.",
                    "semantic_type": "type/FK",
                    "name": "USER_ID",
                    "fk_target_field_id": 15,
                    "field_ref": [
                        "field",
                        40,
                        null
                    ],
                    "effective_type": "type/Integer",
                    "id": 40,
                    "visibility_type": "normal",
                    "display_name": "User ID",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 929,
                            "nil%": 0.0
                        }
                    },
                    "base_type": "type/Integer"
                },
                {
                    "description": "The product ID. This is an internal identifier for the product, NOT the SKU.",
                    "semantic_type": "type/FK",
                    "name": "PRODUCT_ID",
                    "fk_target_field_id": 68,
                    "field_ref": [
                        "field",
                        37,
                        null
                    ],
                    "effective_type": "type/Integer",
                    "id": 37,
                    "visibility_type": "normal",
                    "display_name": "Product ID",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 200,
                            "nil%": 0.0
                        }
                    },
                    "base_type": "type/Integer"
                },
                {
                    "description": "The raw, pre-tax cost of the order. Note that this might be different in the future from the product price due to promotions, credits, etc.",
                    "name": "SUBTOTAL",
                    "field_ref": [
                        "field",
                        41,
                        null
                    ],
                    "effective_type": "type/Float",
                    "id": 41,
                    "visibility_type": "normal",
                    "display_name": "Subtotal",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 340,
                            "nil%": 0.0
                        },
                        "type": {
                            "type/Number": {
                                "min": 15.691943673970439,
                                "q1": 49.74894519060184,
                                "q3": 105.42965746993103,
                                "max": 148.22900526552291,
                                "sd": 32.53705013056317,
                                "avg": 77.01295465356547
                            }
                        }
                    },
                    "base_type": "type/Float"
                },
                {
                    "description": "This is the amount of local and federal taxes that are collected on the purchase. Note that other governmental fees on some products are not included here, but instead are accounted for in the subtotal.",
                    "name": "TAX",
                    "field_ref": [
                        "field",
                        35,
                        null
                    ],
                    "effective_type": "type/Float",
                    "id": 35,
                    "visibility_type": "normal",
                    "display_name": "Tax",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 797,
                            "nil%": 0.0
                        },
                        "type": {
                            "type/Number": {
                                "min": 0.0,
                                "q1": 2.273340386603857,
                                "q3": 5.337275338216307,
                                "max": 11.12,
                                "sd": 2.3206651358900316,
                                "avg": 3.8722100000000004
                            }
                        }
                    },
                    "base_type": "type/Float"
                },
                {
                    "description": "The total billed amount.",
                    "name": "TOTAL",
                    "field_ref": [
                        "field",
                        39,
                        null
                    ],
                    "effective_type": "type/Float",
                    "id": 39,
                    "visibility_type": "normal",
                    "display_name": "Total",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 4426,
                            "nil%": 0.0
                        },
                        "type": {
                            "type/Number": {
                                "min": 8.93914247937167,
                                "q1": 51.34535490743823,
                                "q3": 110.29428389265787,
                                "max": 159.34900526552292,
                                "sd": 34.26469575709948,
                                "avg": 80.35871658771228
                            }
                        }
                    },
                    "base_type": "type/Float"
                },
                {
                    "description": "Discount amount.",
                    "semantic_type": "type/Discount",
                    "name": "DISCOUNT",
                    "field_ref": [
                        "field",
                        33,
                        null
                    ],
                    "effective_type": "type/Float",
                    "id": 33,
                    "visibility_type": "normal",
                    "display_name": "Discount with a very long name",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 701,
                            "nil%": 0.898
                        },
                        "type": {
                            "type/Number": {
                                "min": 0.17088996672584322,
                                "q1": 2.9786226681458743,
                                "q3": 7.338187788658235,
                                "max": 61.69684269960571,
                                "sd": 3.053663125001991,
                                "avg": 5.161255547580326
                            }
                        }
                    },
                    "base_type": "type/Float"
                },
                {
                    "description": "The date and time an order was submitted.",
                    "semantic_type": "type/CreationTimestamp",
                    "unit": "default",
                    "name": "CREATED_AT",
                    "field_ref": [
                        "field",
                        38,
                        {
                            "temporal-unit": "default"
                        }
                    ],
                    "effective_type": "type/DateTime",
                    "id": 38,
                    "visibility_type": "normal",
                    "display_name": "Created At",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 10001,
                            "nil%": 0.0
                        },
                        "type": {
                            "type/DateTime": {
                                "earliest": "2022-04-30T18:56:13.352Z",
                                "latest": "2026-04-19T14:07:15.657Z"
                            }
                        }
                    },
                    "base_type": "type/DateTime"
                },
                {
                    "description": "Number of products bought.",
                    "semantic_type": "type/Quantity",
                    "name": "QUANTITY",
                    "field_ref": [
                        "field",
                        36,
                        null
                    ],
                    "effective_type": "type/Integer",
                    "id": 36,
                    "visibility_type": "normal",
                    "display_name": "Quantity",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 62,
                            "nil%": 0.0
                        },
                        "type": {
                            "type/Number": {
                                "min": 0.0,
                                "q1": 1.755882607764982,
                                "q3": 4.882654507928044,
                                "max": 100.0,
                                "sd": 4.214258386403798,
                                "avg": 3.7015
                            }
                        }
                    },
                    "base_type": "type/Integer"
                },
                {
                    "description": "The name of the user who owns an account",
                    "semantic_type": "type/Name",
                    "name": "NAME",
                    "field_ref": [
                        "field",
                        16,
                        {
                            "source-field": 40
                        }
                    ],
                    "effective_type": "type/Text",
                    "id": 16,
                    "visibility_type": "normal",
                    "display_name": "User ID",
                    "fingerprint": {
                        "global": {
                            "distinct-count": 2499,
                            "nil%": 0.0
                        },
                        "type": {
                            "type/Text": {
                                "percent-json": 0.0,
                                "percent-url": 0.0,
                                "percent-email": 0.0,
                                "percent-state": 0.0,
                                "average-length": 13.532
                            }
                        }
                    },
                    "base_type": "type/Text"
                }
            ]
        },
        "database": 1,
        "query": {
            "source-table": 5,
            "filter": [
                "=",
                [
                    "field",
                    "ID",
                    {
                        "base-type": "type/BigInteger"
                    }
                ],
                [
                    "value",
                    5,
                    {
                        "base_type": "type/BigInteger"
                    }
                ]
            ],
            "fields": [
                [
                    "field",
                    34,
                    null
                ],
                [
                    "field",
                    40,
                    {
                        "metabase.query-processor.middleware.add-dimension-projections/original-field-dimension-id": 2
                    }
                ],
                [
                    "field",
                    37,
                    null
                ],
                [
                    "field",
                    41,
                    null
                ],
                [
                    "field",
                    35,
                    null
                ],
                [
                    "field",
                    39,
                    null
                ],
                [
                    "field",
                    33,
                    null
                ],
                [
                    "field",
                    38,
                    {
                        "temporal-unit": "default"
                    }
                ],
                [
                    "field",
                    36,
                    null
                ],
                [
                    "field",
                    16,
                    {
                        "source-field": 40,
                        "metabase.query-processor.middleware.add-dimension-projections/new-field-dimension-id": 2,
                        "join-alias": "PEOPLE__via__USER_ID"
                    }
                ]
            ],
            "joins": [
                {
                    "alias": "PEOPLE__via__USER_ID",
                    "strategy": "left-join",
                    "source-table": 3,
                    "condition": [
                        "=",
                        [
                            "field",
                            40,
                            null
                        ],
                        [
                            "field",
                            15,
                            {
                                "join-alias": "PEOPLE__via__USER_ID"
                            }
                        ]
                    ],
                    "fk-field-id": 40
                }
            ],
            "limit": 2000,
            "metabase.query-processor.middleware.limit/original-limit": null
        }
    },
    "ex-data": {
        "type": "invalid-query",
        "clause": [
            "field",
            "ID",
            {
                "base-type": "type/BigInteger"
            }
        ],
        "query": {
            "source-table": 5,
            "filter": [
                "=",
                [
                    "field",
                    "ID",
                    {
                        "base-type": "type/BigInteger"
                    }
                ],
                [
                    "value",
                    5,
                    {
                        "base_type": "type/BigInteger"
                    }
                ]
            ],
            "fields": [
                [
                    "field",
                    34,
                    null
                ],
                [
                    "field",
                    40,
                    {
                        "metabase.query-processor.middleware.add-dimension-projections/original-field-dimension-id": 2
                    }
                ],
                [
                    "field",
                    37,
                    null
                ],
                [
                    "field",
                    41,
                    null
                ],
                [
                    "field",
                    35,
                    null
                ],
                [
                    "field",
                    39,
                    null
                ],
                [
                    "field",
                    33,
                    null
                ],
                [
                    "field",
                    38,
                    {
                        "temporal-unit": "default"
                    }
                ],
                [
                    "field",
                    36,
                    null
                ],
                [
                    "field",
                    16,
                    {
                        "source-field": 40,
                        "metabase.query-processor.middleware.add-dimension-projections/new-field-dimension-id": 2,
                        "join-alias": "PEOPLE__via__USER_ID"
                    }
                ]
            ],
            "joins": [
                {
                    "alias": "PEOPLE__via__USER_ID",
                    "strategy": "left-join",
                    "source-table": 3,
                    "condition": [
                        "=",
                        [
                            "field",
                            40,
                            null
                        ],
                        [
                            "field",
                            15,
                            {
                                "join-alias": "PEOPLE__via__USER_ID"
                            }
                        ]
                    ],
                    "fk-field-id": 40
                }
            ],
            "limit": 2000,
            "metabase.query-processor.middleware.limit/original-limit": null
        }
    },
    "data": {
        "rows": [],
        "cols": []
    }
}

Information about your Metabase installation

master at ef9fb05, 0.49.0-RC2

Works in v48. Works with questions.

Severity

P1

@kamilmielnik kamilmielnik added Type:Bug Product defects .Needs Triage .Backend .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. .Regression/master Regression that is only present on master, or bug in new upcoming feature .Team/QueryProcessor :hammer_and_wrench: Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Reporting/Dashboards and removed .Needs Triage labels Mar 11, 2024
@perivamsi perivamsi added this to the 0.49 milestone Mar 11, 2024
@bshepherdson bshepherdson self-assigned this Mar 11, 2024
@bshepherdson
Copy link
Contributor

bshepherdson commented Mar 11, 2024

The trouble here is a mismatch between the parameter applying to the model's own inner query or to a wrapper using the model as its source-query.

The parameter has target: ["dimension", ["field", "ID", {"base-type": "type/Integer"}]] which is correct on a wrapper query with {source_table: "card__123"}. But the parameter is really being applied to the model directly.

The preprocessed query looks like this (MLv2):

{:stages [{:source-table 5
           :filters [[:= [:field {} "ID"] [:value {} 5]]]}

which is wrong.

Confirmed this is a BE issue.

bshepherdson added a commit that referenced this issue Mar 11, 2024
This matches how models are visualized, and how the parameters are
attached to them in the first place - an extra ad-hoc query is wrapped
around the model.

Because of that wrapping, a parameter will be targeting a model's field
by name rather than by ID, but that parameter cannot be applied directly
on the model's last stage.

Fixes #39940.
@kamilmielnik kamilmielnik removed the .Regression/master Regression that is only present on master, or bug in new upcoming feature label Mar 12, 2024
bshepherdson added a commit that referenced this issue Mar 12, 2024
This matches how models are visualized, and how the parameters are
attached to them in the first place - an extra ad-hoc query is wrapped
around the model.

Because of that wrapping, a parameter will be targeting a model's field
by name rather than by ID, but that parameter cannot be applied directly
on the model's last stage.

Fixes #39940.
bshepherdson added a commit that referenced this issue Mar 12, 2024
…39963)

This matches how models are visualized, and how the parameters are
attached to them in the first place - an extra ad-hoc query is wrapped
around the model.

Because of that wrapping, a parameter will be targeting a model's field
by name rather than by ID, but that parameter cannot be applied directly
on the model's last stage.

Fixes #39940.
paoliniluis pushed a commit that referenced this issue Mar 13, 2024
…tra stage (#39963)" (#40047)

Fixes #39940.

Co-authored-by: Braden Shepherdson <braden@metabase.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Backend Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. Reporting/Dashboards .Team/QueryProcessor :hammer_and_wrench: Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants