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

Bigquery: Can't search field values for required partition tables #40673

Closed
Timelessprod opened this issue Mar 27, 2024 · 10 comments · Fixed by #40767
Closed

Bigquery: Can't search field values for required partition tables #40673

Timelessprod opened this issue Mar 27, 2024 · 10 comments · Fixed by #40767
Assignees
Labels
.Backend Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Querying/Processor .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. .Team/BackendComponents also known as BEC Type:Bug Product defects
Milestone

Comments

@Timelessprod
Copy link

Describe the bug

When creating a question from a table that has a lot of rows (multiple 10.000s) and some filters of type "Is"/"Is not" on a same text column, the UI break and no data is being displayed. Instead a warning sign is showing with message "Something's gone wrong" when hovering. This happens both in the visualiser and editor modes (see screenshots below).

In my case I loaded 48 months of data partitions (with Dt = 48 last months) and had already set filters on column "Type" to not be "BANK_DEPOSIT" nor "CARD" and I was about to add another value to exclude. Please note that in the editor mode, even when the bug occur I can click the preview button next to the Filter section and see actual results, but the 3rd filter was not applied and the whole filter section is not showing anymore. It also sometimes happen when applying the first filter.

This bug appeared after updating from v0.48.3 to v0.49.1. I cannot give an exact threshold but it happens with tables that vae around 40.000 to 80.000 rows. Under 10.000 we don't seem to have this bug. In some cases we can use "contains"/"does not contain" and it will work, but for some other cases we want a specific filtering on the whole value and not just a substring.

In the visualiser mode the bug seems to not happen when creating filter by clicking on a cell and apply a "Is" or "Is not" on the cell's value. When creating the filter from the column header it almost always occurs on the first filter.

Visualiser mode:
Screenshot 2024-03-27 at 14 26 42

Editor mode:
Screenshot 2024-03-27 at 14 32 02

To Reproduce

  1. Create a question from a table that has a lot of rows (more than 10.000)

Either in editor mode or visualiser mode:
2. Apply 2 filters on a same column with parameter "Is" or "Is not"
3. Apply a third filter with "Is" or "Is not"
4. See the UI failing to display any data and not applying the later filter

Expected behavior

I expect to be able to add as many filters I want to a same column.

Logs

[a76dbbcd-e5eb-4647-9e35-862bcc736a63] 2024-03-27T14:42:27+01:00 ERROR metabase.query-processor.middleware.catch-exceptions Error processing query: 400 Bad Request
POST https://www.googleapis.com/bigquery/v2/projects/<project_name>/queries
{
  "code": 400,
  "errors": [
    {
      "domain": "global",
      "location": "q",
      "locationType": "parameter",
      "message": "Cannot query over table 'datawarehouse.table_name' without a filter over column(s) 'dt' that can be used for partition elimination",
      "reason": "invalidQuery"
    }
  ],
  "message": "Cannot query over table 'datawarehouse.table_name' without a filter over column(s) 'dt' that can be used for partition elimination",
  "status": "INVALID_ARGUMENT"
}
{:database_id 2,
 :started_at #t "2024-03-27T13:42:27.200380860Z[Etc/UTC]",
 :via
 [{:status :failed,
   :class com.google.cloud.bigquery.BigQueryException,
   :error
   "Cannot query over table 'datawarehouse.table_name' without a filter over column(s) 'dt' that can be used for partition elimination",
   :stacktrace
   ["com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.translate(HttpBigQueryRpc.java:114)"
    "com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.queryRpc(HttpBigQueryRpc.java:728)"
    "com.google.cloud.bigquery.BigQueryImpl$35.call(BigQueryImpl.java:1358)"
    "com.google.cloud.bigquery.BigQueryImpl$35.call(BigQueryImpl.java:1355)"
    "com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:103)"
    "com.google.cloud.bigquery.BigQueryRetryHelper.run(BigQueryRetryHelper.java:86)"
    "com.google.cloud.bigquery.BigQueryRetryHelper.runWithRetries(BigQueryRetryHelper.java:49)"
    "com.google.cloud.bigquery.BigQueryImpl.queryRpc(BigQueryImpl.java:1354)"
    "com.google.cloud.bigquery.BigQueryImpl.query(BigQueryImpl.java:1342)"
    "--> driver.bigquery_cloud_sdk$execute_bigquery$fn__128578.invoke(bigquery_cloud_sdk.clj:343)"]}
  {:status :failed,
   :class java.util.concurrent.ExecutionException,
   :error
   "com.google.cloud.bigquery.BigQueryException: Cannot query over table 'datawarehouse.table_name' without a filter over column(s) 'dt' that can be used for partition elimination",
   :stacktrace
   ["java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)"
    "java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)"
    "clojure.core$deref_future.invokeStatic(core.clj:2317)"
    "clojure.core$future_call$reify__8544.deref(core.clj:7042)"
    "clojure.core$deref.invokeStatic(core.clj:2337)"
    "clojure.core$deref.invoke(core.clj:2323)"
    "--> driver.bigquery_cloud_sdk$execute_bigquery.invokeStatic(bigquery_cloud_sdk.clj:331)"
    "driver.bigquery_cloud_sdk$execute_bigquery.invoke(bigquery_cloud_sdk.clj:327)"
    "driver.bigquery_cloud_sdk$execute_bigquery_on_db.invokeStatic(bigquery_cloud_sdk.clj:371)"
    "driver.bigquery_cloud_sdk$execute_bigquery_on_db.invoke(bigquery_cloud_sdk.clj:369)"
    "driver.bigquery_cloud_sdk$_STAR_process_native_STAR_$thunk__128622.invoke(bigquery_cloud_sdk.clj:419)"
    "driver.bigquery_cloud_sdk$_STAR_process_native_STAR_.invokeStatic(bigquery_cloud_sdk.clj:427)"
    "driver.bigquery_cloud_sdk$_STAR_process_native_STAR_.invoke(bigquery_cloud_sdk.clj:412)"
    "driver.bigquery_cloud_sdk$fn__128629.invokeStatic(bigquery_cloud_sdk.clj:448)"
    "driver.bigquery_cloud_sdk$fn__128629.invoke(bigquery_cloud_sdk.clj:440)"
    "query_processor.context$executef.invokeStatic(context.clj:60)"
    "query_processor.context$executef.invoke(context.clj:49)"
    "query_processor.context.default$default_runf.invokeStatic(default.clj:44)"
    "query_processor.context.default$default_runf.invoke(default.clj:42)"
    "query_processor.context$runf.invokeStatic(context.clj:46)"
    "query_processor.context$runf.invoke(context.clj:40)"
    "query_processor.reducible$identity_qp.invokeStatic(reducible.clj:39)"
    "query_processor.reducible$identity_qp.invoke(reducible.clj:36)"
    "query_processor.middleware.cache$maybe_return_cached_results$maybe_return_cached_results_STAR___71992.invoke(cache.clj:229)"
    "query_processor.middleware.permissions$check_query_permissions$fn__66378.invoke(permissions.clj:140)"
    "query_processor.middleware.enterprise$check_download_permissions_middleware$fn__71813.invoke(enterprise.clj:51)"
    "query_processor.middleware.enterprise$maybe_apply_column_level_perms_check_middleware$fn__71823.invoke(enterprise.clj:64)"
    "query_processor.middleware.mbql_to_native$mbql__GT_native$fn__71255.invoke(mbql_to_native.clj:24)"
    "query_processor$fn__73137$combined_post_process__73142$combined_post_process_STAR___73143.invoke(query_processor.clj:262)"
    "query_processor$fn__73137$combined_pre_process__73138$combined_pre_process_STAR___73139.invoke(query_processor.clj:259)"
    "query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__66475.invoke(fetch_source_query.clj:303)"
    "query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__71903$fn__71907.invoke(resolve_database_and_driver.clj:77)"
    "driver$do_with_driver.invokeStatic(driver.clj:97)"
    "driver$do_with_driver.invoke(driver.clj:92)"
    "query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__71903.invoke(resolve_database_and_driver.clj:76)"
    "query_processor.middleware.store$initialize_store$fn__67081$fn__67082.invoke(store.clj:14)"
    "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:169)"
    "query_processor.store$do_with_metadata_provider.invoke(store.clj:150)"
    "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:158)"
    "query_processor.store$do_with_metadata_provider.invoke(store.clj:150)"
    "query_processor.middleware.store$initialize_store$fn__67081.invoke(store.clj:13)"
    "query_processor.middleware.resolve_database_and_driver$resolve_database$fn__71900.invoke(resolve_database_and_driver.clj:60)"
    "query_processor.middleware.normalize_query$normalize$fn__72205.invoke(normalize_query.clj:38)"
    "query_processor.middleware.enterprise$fn__71840$handle_audit_app_internal_queries__71841$fn__71843.invoke(enterprise.clj:96)"
    "query_processor.middleware.enterprise$handle_audit_app_internal_queries_middleware$fn__71851.invoke(enterprise.clj:103)"
    "query_processor.middleware.constraints$mark_needs_default_userland_constraints$fn__70966.invoke(constraints.clj:104)"
    "query_processor.middleware.process_userland_query$process_userland_query$fn__72136.invoke(process_userland_query.clj:156)"
    "query_processor.middleware.catch_exceptions$catch_exceptions$fn__72737.invoke(catch_exceptions.clj:171)"
    "query_processor.reducible$async_qp$qp_STAR___62625$thunk__62627.invoke(reducible.clj:126)"
    "query_processor.reducible$async_qp$qp_STAR___62625.invoke(reducible.clj:132)"
    "query_processor.reducible$sync_qp$qp_STAR___62637.doInvoke(reducible.clj:153)"
    "query_processor$process_userland_query.invokeStatic(query_processor.clj:402)"
    "query_processor$process_userland_query.doInvoke(query_processor.clj:398)"
    "query_processor$process_query_and_save_execution_BANG_.invokeStatic(query_processor.clj:416)"
    "query_processor$process_query_and_save_execution_BANG_.invoke(query_processor.clj:406)"
    "query_processor$process_query_and_save_with_max_results_constraints_BANG_.invokeStatic(query_processor.clj:431)"
    "query_processor$process_query_and_save_with_max_results_constraints_BANG_.invoke(query_processor.clj:421)"
    "api.dataset$run_query_async$fn__93630.invoke(dataset.clj:79)"
    "query_processor.streaming$streaming_response_STAR_$fn__53145$fn__53147.invoke(streaming.clj:168)"
    "query_processor.streaming$streaming_response_STAR_$fn__53145.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__43756.invoke(streaming_response.clj:88)"]}
  {:status :failed,
   :class clojure.lang.ExceptionInfo,
   :error
   "Error executing query: com.google.cloud.bigquery.BigQueryException: Cannot query over table 'datawarehouse.table_name' without a filter over column(s) 'dt' that can be used for partition elimination",
   :stacktrace
   ["--> driver.bigquery_cloud_sdk$throw_invalid_query.invokeStatic(bigquery_cloud_sdk.clj:323)"
    "driver.bigquery_cloud_sdk$throw_invalid_query.invoke(bigquery_cloud_sdk.clj:322)"
    "driver.bigquery_cloud_sdk$execute_bigquery.invokeStatic(bigquery_cloud_sdk.clj:367)"
    "driver.bigquery_cloud_sdk$execute_bigquery.invoke(bigquery_cloud_sdk.clj:327)"
    "driver.bigquery_cloud_sdk$execute_bigquery_on_db.invokeStatic(bigquery_cloud_sdk.clj:371)"
    "driver.bigquery_cloud_sdk$execute_bigquery_on_db.invoke(bigquery_cloud_sdk.clj:369)"
    "driver.bigquery_cloud_sdk$_STAR_process_native_STAR_$thunk__128622.invoke(bigquery_cloud_sdk.clj:419)"
    "driver.bigquery_cloud_sdk$_STAR_process_native_STAR_.invokeStatic(bigquery_cloud_sdk.clj:427)"
    "driver.bigquery_cloud_sdk$_STAR_process_native_STAR_.invoke(bigquery_cloud_sdk.clj:412)"
    "driver.bigquery_cloud_sdk$fn__128629.invokeStatic(bigquery_cloud_sdk.clj:448)"
    "driver.bigquery_cloud_sdk$fn__128629.invoke(bigquery_cloud_sdk.clj:440)"
    "query_processor.context$executef.invokeStatic(context.clj:60)"
    "query_processor.context$executef.invoke(context.clj:49)"
    "query_processor.context.default$default_runf.invokeStatic(default.clj:44)"
    "query_processor.context.default$default_runf.invoke(default.clj:42)"
    "query_processor.context$runf.invokeStatic(context.clj:46)"
    "query_processor.context$runf.invoke(context.clj:40)"
    "query_processor.reducible$identity_qp.invokeStatic(reducible.clj:39)"
    "query_processor.reducible$identity_qp.invoke(reducible.clj:36)"
    "query_processor.middleware.cache$maybe_return_cached_results$maybe_return_cached_results_STAR___71992.invoke(cache.clj:229)"
    "query_processor.middleware.permissions$check_query_permissions$fn__66378.invoke(permissions.clj:140)"
    "query_processor.middleware.enterprise$check_download_permissions_middleware$fn__71813.invoke(enterprise.clj:51)"
    "query_processor.middleware.enterprise$maybe_apply_column_level_perms_check_middleware$fn__71823.invoke(enterprise.clj:64)"
    "query_processor.middleware.mbql_to_native$mbql__GT_native$fn__71255.invoke(mbql_to_native.clj:24)"
    "query_processor$fn__73137$combined_post_process__73142$combined_post_process_STAR___73143.invoke(query_processor.clj:262)"
    "query_processor$fn__73137$combined_pre_process__73138$combined_pre_process_STAR___73139.invoke(query_processor.clj:259)"
    "query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__66475.invoke(fetch_source_query.clj:303)"
    "query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__71903$fn__71907.invoke(resolve_database_and_driver.clj:77)"
    "driver$do_with_driver.invokeStatic(driver.clj:97)"
    "driver$do_with_driver.invoke(driver.clj:92)"
    "query_processor.middleware.resolve_database_and_driver$resolve_driver_and_database_local_values$fn__71903.invoke(resolve_database_and_driver.clj:76)"
    "query_processor.middleware.store$initialize_store$fn__67081$fn__67082.invoke(store.clj:14)"
    "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:169)"
    "query_processor.store$do_with_metadata_provider.invoke(store.clj:150)"
    "query_processor.store$do_with_metadata_provider.invokeStatic(store.clj:158)"
    "query_processor.store$do_with_metadata_provider.invoke(store.clj:150)"
    "query_processor.middleware.store$initialize_store$fn__67081.invoke(store.clj:13)"
    "query_processor.middleware.resolve_database_and_driver$resolve_database$fn__71900.invoke(resolve_database_and_driver.clj:60)"
    "query_processor.middleware.normalize_query$normalize$fn__72205.invoke(normalize_query.clj:38)"
    "query_processor.middleware.enterprise$fn__71840$handle_audit_app_internal_queries__71841$fn__71843.invoke(enterprise.clj:96)"
    "query_processor.middleware.enterprise$handle_audit_app_internal_queries_middleware$fn__71851.invoke(enterprise.clj:103)"
    "query_processor.middleware.constraints$mark_needs_default_userland_constraints$fn__70966.invoke(constraints.clj:104)"
    "query_processor.middleware.process_userland_query$process_userland_query$fn__72136.invoke(process_userland_query.clj:156)"
    "query_processor.middleware.catch_exceptions$catch_exceptions$fn__72737.invoke(catch_exceptions.clj:171)"
    "query_processor.reducible$async_qp$qp_STAR___62625$thunk__62627.invoke(reducible.clj:126)"
    "query_processor.reducible$async_qp$qp_STAR___62625.invoke(reducible.clj:132)"
    "query_processor.reducible$sync_qp$qp_STAR___62637.doInvoke(reducible.clj:153)"
    "query_processor$process_userland_query.invokeStatic(query_processor.clj:402)"
    "query_processor$process_userland_query.doInvoke(query_processor.clj:398)"
    "query_processor$process_query_and_save_execution_BANG_.invokeStatic(query_processor.clj:416)"
    "query_processor$process_query_and_save_execution_BANG_.invoke(query_processor.clj:406)"
    "query_processor$process_query_and_save_with_max_results_constraints_BANG_.invokeStatic(query_processor.clj:431)"
    "query_processor$process_query_and_save_with_max_results_constraints_BANG_.invoke(query_processor.clj:421)"
    "api.dataset$run_query_async$fn__93630.invoke(dataset.clj:79)"
    "query_processor.streaming$streaming_response_STAR_$fn__53145$fn__53147.invoke(streaming.clj:168)"
    "query_processor.streaming$streaming_response_STAR_$fn__53145.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__43756.invoke(streaming_response.clj:88)"],
   :error_type :invalid-query,
   :ex-data
   {:type :invalid-query,
    :sql
    "-- Metabase:: userID: 5 queryType: MBQL queryHash: ace1a8506501d6f6f047d0b9fc33731f15926d7a0b7c98cf503090c3aeb863a6\nSELECT <`table_name`.`column` AS `column` for all columns> LIMIT 2000",
    :parameters nil}}],
 :action_id nil,
 :error_type :invalid-query,
 :json_query
 {:database 2,
  :type "query",
  :query {:source-table 824},
  :parameters [],
  :middleware {:js-int-to-string? true, :add-default-userland-constraints? true}},
 :native
 {:query
  "SELECT <table_name.column AS column> LIMIT 1048575",
  :params nil,
  :table-name "table_name",
  :mbql? true},
 :status :failed,
 :class com.google.api.client.googleapis.json.GoogleJsonResponseException,
 :stacktrace
 ["com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)"
  "com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)"
  "com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)"
  "com.google.api.client.googleapis.services.AbstractGoogleClientRequest$3.interceptResponse(AbstractGoogleClientRequest.java:466)"
  "com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)"
  "com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:552)"
  "com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:493)"
  "com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:603)"
  "com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc.queryRpc(HttpBigQueryRpc.java:726)"
  "com.google.cloud.bigquery.BigQueryImpl$35.call(BigQueryImpl.java:1358)"
  "com.google.cloud.bigquery.BigQueryImpl$35.call(BigQueryImpl.java:1355)"
  "com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:103)"
  "com.google.cloud.bigquery.BigQueryRetryHelper.run(BigQueryRetryHelper.java:86)"
  "com.google.cloud.bigquery.BigQueryRetryHelper.runWithRetries(BigQueryRetryHelper.java:49)"
  "com.google.cloud.bigquery.BigQueryImpl.queryRpc(BigQueryImpl.java:1354)"
  "com.google.cloud.bigquery.BigQueryImpl.query(BigQueryImpl.java:1342)"
  "--> driver.bigquery_cloud_sdk$execute_bigquery$fn__128578.invoke(bigquery_cloud_sdk.clj:343)"],
 :card_id nil,
 :context :ad-hoc,
 :error
 "400 Bad Request\nPOST https://www.googleapis.com/bigquery/v2/projects/<project_name>/queries\n{\n  \"code\": 400,\n  \"errors\": [\n    {\n      \"domain\": \"global\",\n      \"location\": \"q\",\n      \"locationType\": \"parameter\",\n      \"message\": \"Cannot query over table 'datawarehouse.table_name' without a filter over column(s) 'dt' that can be used for partition elimination\",\n      \"reason\": \"invalidQuery\"\n    }\n  ],\n  \"message\": \"Cannot query over table 'datawarehouse.table_name' without a filter over column(s) 'dt' that can be used for partition elimination\",\n  \"status\": \"INVALID_ARGUMENT\"\n}",
 :row_count 0,
 :running_time 0,
 :preprocessed
 {:database 2,
  :type :query,
  :query
  {:source-table 824,
   :fields
   [[:field 15900 nil]
    [:field 15918 nil]
    [:field 15934 nil]
    [:field 15932 nil]
    [:field 15892 nil]
    [:field 15920 nil]
    [:field 15904 nil]
    [:field 15895 nil]
    [:field 21987 nil]
    [:field 15891 nil]
    [:field 21986 nil]
    [:field 15901 nil]
    [:field 15924 nil]
    [:field 15928 nil]
    [:field 15903 nil]
    [:field 15935 nil]
    [:field 15908 nil]
    [:field 33357 nil]
    [:field 15939 nil]
    [:field 15888 {:temporal-unit :default}]
    [:field 15905 {:temporal-unit :default}]
    [:field 15912 {:temporal-unit :default}]
    [:field 15926 nil]
    [:field 15938 nil]
    [:field 15890 nil]
    [:field 15907 nil]
    [:field 15936 nil]
    [:field 15931 nil]
    [:field 15927 nil]
    [:field 15937 nil]
    [:field 15898 nil]
    [:field 15933 nil]
    [:field 15915 nil]
    [:field 15911 nil]
    [:field 15917 nil]
    [:field 15930 nil]
    [:field 22888 nil]
    [:field 15916 nil]
    [:field 16817 nil]
    [:field 18897 nil]
    [:field 20900 nil]
    [:field 20901 nil]
    [:field 20902 nil]
    [:field 20741 nil]
    [:field 20742 {:temporal-unit :default}]
    [:field 27000 nil]
    [:field 30181 nil]
    [:field 27643 nil]
    [:field 27642 nil]
    [:field 27641 nil]
    [:field 27644 nil]
    [:field 27640 nil]
    [:field 31069 nil]
    [:field 30184 nil]
    [:field 30182 nil]
    [:field 31070 nil]
    [:field 15897 nil]
    [:field 15910 nil]
    [:field 15894 nil]
    [:field 15923 nil]
    [:field 15913 nil]
    [:field 15941 nil]
    [:field 15906 nil]
    [:field 15899 nil]
    [:field 15889 nil]
    [:field 15887 nil]
    [:field 15929 nil]
    [:field 15896 nil]
    [:field 15921 nil]
    [:field 15909 nil]
    [:field 15925 nil]
    [:field 15940 nil]
    [:field 15886 nil]
    [:field 15914 nil]
    [:field 15893 nil]
    [:field 15919 nil]
    [:field 15922 nil]
    [:field 21511 nil]
    [:field 30183 nil]
    [:field 30185 nil]
    [:field 15902 {:temporal-unit :default}]],
   :limit 1048575,
   :metabase.query-processor.middleware.limit/original-limit nil},
  :middleware {:js-int-to-string? true, :add-default-userland-constraints? true},
  :info {:executed-by 5, :context :ad-hoc}},
 :data {:rows [], :cols []}}

Information about your Metabase installation

{
  "browser-info": {
    "language": "en-GB",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "ANSI_X3.4-1968",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "17.0.10+7-Debian-1deb12u1",
    "java.vendor": "Debian",
    "java.vendor.url": "https://tracker.debian.org/openjdk-17",
    "java.version": "17.0.10",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "17.0.10+7-Debian-1deb12u1",
    "os.name": "Linux",
    "os.version": "6.1.58+",
    "user.language": "en",
    "user.timezone": "Etc/UTC"
  },
  "metabase-info": {
    "databases": [
      "bigquery-cloud-sdk"
    ],
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "13.13"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.7.2"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2024-03-21",
      "tag": "v0.49.1",
      "hash": "54ef5e9"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

Severity

Blocking some users

Additional context

Looking at the logs it seems that there's an issue with inferring the partitionning on our "dt" column even though there's an existing filter on dt = last 48 months given prior the bug occurs.

@ranquild ranquild added Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness Querying/Processor .Backend .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. and removed .Needs Triage labels Mar 27, 2024
@bshepherdson bshepherdson added this to the 0.49.2 milestone Mar 27, 2024
@darksciencebase darksciencebase added the .Team/BackendComponents also known as BEC label Mar 27, 2024
@qnkhuat
Copy link
Contributor

qnkhuat commented Mar 28, 2024

Looking at the logs it seems that there's an issue with inferring the partitionning on our "dt" column even though there's an existing filter on dt = last 48 months given prior the bug occurs.

not sure how much you redacted, but looking at the query from the log:

"SELECT <table_name.column AS column> LIMIT 1048575",

I don't see the filter clause on the partitioned column anywhere. Did you have a filter on the partitioned column when you built the query? if yes, could you add the full native query that were executed, (with redacted info of course).

Also, I've tried to reproduce with this table

CREATE TABLE big_table
  (
     id       INT64,
     category STRING
  )  
PARTITION BY _PARTITIONDATE
OPTIONS(require_partition_filter = TRUE);

INSERT INTO big_table
            (
                        id,
                        category
            )
SELECT id,
       CASE
              WHEN mod(id, 5) = 0 THEN 'A'
              WHEN mod(id, 5) = 1 THEN 'B'
              WHEN mod(id, 5) = 2 THEN 'C'
              WHEN mod(id, 5) = 3 THEN 'D'
              WHEN mod(id, 5) = 4 THEN 'E'
       END AS category
FROM   (
              SELECT row_number() OVER() AS id
              FROM   unnest(generate_array(1, 50000)) ) 

tried to add a few filters and it works fine
Screenshot 2024-03-28 at 11 32 25

@Timelessprod
Copy link
Author

Thanks for the feedback.

On my first screenshot the partition filter is visible, it's the "Dt is in the previous 48 months" (look on the top left corner) as this column represent the partition used on BigQuery. On the second screenshot, it is not visible because the bug makes the whole filter section of the editor disappearing.

Here's the native query generated by Metabase in the bug case. I copied it from the editor mode just after the bug occured. For privacy reasons I give fake column names.

SELECT
  `datawarehouse.tablename`.`column_1` AS `column_1`,
  `datawarehouse.tablename`.`column_2` AS `column_2`,
  `datawarehouse.tablename`.`column_3` AS `column_3`,
  `datawarehouse.tablename`.`column_4` AS `column_4`,
  -- [...]
  `datawarehouse.tablename`.`column_78` AS `column_78`,
  `datawarehouse.tablename`.`type` AS `type`,
  `datawarehouse.tablename`.`dt` AS `dt`
FROM
  `datawarehouse.tablename`
WHERE
  (
    `datawarehouse.tablename`.`dt` >= DATE_TRUNC(DATE_ADD(CURRENT_DATE(), INTERVAL -48 month), month)
  )
   AND (
    `datawarehouse.tablename`.`dt` < DATE_TRUNC(DATE_ADD(CURRENT_DATE(), INTERVAL 1 month), month)
  )
LIMIT
  1048575

And we can see that the filter on column type that I wanted to add when the bug occured is not showing and that no filter at all is showing in the logs indeed.

We have it on multiple users and on different tables with filters on different columns but seems to be only text type column with "Is" or "Is not" filter categories.

I hope these information help. Let me know if you need more context.

@Timelessprod
Copy link
Author

I don't know the behavior of Metabase for this, but could it be that when we are typing the value for a text filter, Metabase tries to fetch the database for possible values in this fields (to proivide hints for the user in real time), but since it doesn't provide a Dt (partition) filter while doing this internal sub-query, it gets an error from the database server (BigQuery in my case) and don't handle it properly (by just not showing hints for possible values for example), causing the UI bug ?

@crisptrutski
Copy link
Contributor

This will need to be pushed out to 49.3 - we have a lot of important fixes pending and do not want to delay them further.

@crisptrutski crisptrutski modified the milestones: 0.49.2, 0.49.3 Mar 28, 2024
@qnkhuat
Copy link
Contributor

qnkhuat commented Mar 29, 2024

I don't know the behavior of Metabase for this, but could it be that when we are typing the value for a text filter, Metabase tries to fetch the database for possible values in this fields (to proivide hints for the user in real time), but since it doesn't provide a Dt (partition) filter while doing this internal sub-query, it gets an error from the database server (BigQuery in my case) and don't handle it properly (by just not showing hints for possible values for example), causing the UI bug ?

@Timelessprod you're absolutely correct ! the bug is in the query we make to search field values.

@qnkhuat qnkhuat changed the title Not data displayed when filtering on huge table Bigquery: Can't search field values for required partition tables Mar 29, 2024
@qnkhuat
Copy link
Contributor

qnkhuat commented Apr 2, 2024

#40777 will fix the crashing issue.

I'm working on #40767 to make the query return sensible field values.

Remove from 49.3 milestone as this no longer is a regression.

@qnkhuat qnkhuat removed this from the 0.49.3 milestone Apr 2, 2024
@qnkhuat
Copy link
Contributor

qnkhuat commented Apr 4, 2024

The fix will be included in 49.4

@darksciencebase
Copy link
Contributor

@qnkhuat do you mean 49.4? we released 49.3 already

@qnkhuat
Copy link
Contributor

qnkhuat commented Apr 4, 2024

yes. should be 49.4.

@qnkhuat qnkhuat added this to the 0.49.4 milestone Apr 4, 2024
@Timelessprod
Copy link
Author

Perfect thank you very much for the fix!

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 Querying/Processor .Regression Bugs that were previously fixed and/or bugs unintentionally shipped with new features. .Team/BackendComponents also known as BEC Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants