Metabase: Attempting to call unbound fn

Facing below error even if removed cast field:
Attempting to call unbound fn: #'metabase.driver.sql.query-processor/cast-field-if-needed

Initially, we have added cast in sql query by which this error occurred.
But now we have reverted code and removed cast field from sql query and still getting same error.

Does anyone have any idea regarding this issue, please let me know your thoughts.

Thanks

Hi @aalap

  1. Post "Diagnostic Info" from Admin > Troubleshooting, and which database type you're querying.
  2. Post the full stacktrace error from Admin > Troubleshooting > Logs.
  3. Post the query.

Hey @flamber,
Thanks for the response.
Please find "Diagnostic Info" as below:

{
  "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/90.0.4430.212 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.7+10",
    "java.vendor": "AdoptOpenJDK",
    "java.vendor.url": "https://adoptopenjdk.net/",
    "java.version": "11.0.7",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.7+10",
    "os.name": "Linux",
    "os.version": "4.14.225-168.357.amzn2.x86_64",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "athena",
      "h2"
    ],
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "11.10"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.2.8"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2020-12-03",
      "tag": "v0.37.3",
      "branch": "release-x.37.x",
      "hash": "2f1e783"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

Database: PostresSQL

Logs:

[150d2944-f0d9-4d35-a5d3-855fedfd9dbc] 2021-05-20T06:37:25+05:30 ERROR metabase.sync.util Error fingerprinting Table 92 'report_glue_db_dev.0e1c74d0_1b18_4d52_bb07_05373ae6be4a_csv'
java.lang.IllegalStateException: Attempting to call unbound fn: #'metabase.driver.sql.query-processor/cast-field-if-needed
	at clojure.lang.Var$Unbound.throwArity(Var.java:45)
	at clojure.lang.AFn.invoke(AFn.java:40)
	at metabase.driver.query_processor$__GT_honeysql.invokeStatic(query_processor.clj:28)
	at metabase.driver.query_processor$__GT_honeysql.invoke(query_processor.clj:20)
	at metabase.driver.athena$fn__471.invokeStatic(athena.clj:145)
	at metabase.driver.athena$fn__471.invoke(athena.clj:145)
	at clojure.lang.MultiFn.invoke(MultiFn.java:234)
	at metabase.driver.sql.query_processor$fn__68564.invokeStatic(query_processor.clj:284)
	at metabase.driver.sql.query_processor$fn__68564.invoke(query_processor.clj:282)
	at clojure.lang.MultiFn.invoke(MultiFn.java:234)
	at metabase.driver.sql.query_processor$as.invokeStatic(query_processor.clj:549)
	at metabase.driver.sql.query_processor$as.invoke(query_processor.clj:529)
	at metabase.driver.sql.query_processor$fn__68964$iter__68966__68970$fn__68971$fn__68972.invoke(query_processor.clj:587)
	at metabase.driver.sql.query_processor$fn__68964$iter__68966__68970$fn__68971.invoke(query_processor.clj:586)
	at clojure.lang.LazySeq.sval(LazySeq.java:42)
	at clojure.lang.LazySeq.seq(LazySeq.java:51)
	at clojure.lang.RT.seq(RT.java:535)
	at clojure.lang.LazilyPersistentVector.create(LazilyPersistentVector.java:44)
	at clojure.core$vec.invokeStatic(core.clj:377)
	at clojure.core$vec.invoke(core.clj:367)
	at metabase.driver.sql.query_processor$fn__68964.invokeStatic(query_processor.clj:586)
	at metabase.driver.sql.query_processor$fn__68964.invoke(query_processor.clj:583)
	at clojure.lang.MultiFn.invoke(MultiFn.java:244)
	at metabase.driver.sql.query_processor$apply_top_level_clauses$fn__69225.invoke(query_processor.clj:845)
	at clojure.lang.ArraySeq.reduce(ArraySeq.java:116)
	at clojure.core$reduce.invokeStatic(core.clj:6827)
	at clojure.core$reduce.invoke(core.clj:6810)
	at metabase.driver.sql.query_processor$apply_top_level_clauses.invokeStatic(query_processor.clj:843)
	at metabase.driver.sql.query_processor$apply_top_level_clauses.invoke(query_processor.clj:839)
	at metabase.driver.sql.query_processor$apply_clauses.invokeStatic(query_processor.clj:924)
	at metabase.driver.sql.query_processor$apply_clauses.invoke(query_processor.clj:909)
	at metabase.driver.sql.query_processor$apply_source_query$fn__69231.invoke(query_processor.clj:872)
	at metabase.driver.sql.query_processor$apply_source_query.invokeStatic(query_processor.clj:871)
	at metabase.driver.sql.query_processor$apply_source_query.invoke(query_processor.clj:864)
	at metabase.driver.sql.query_processor$apply_clauses.invokeStatic(query_processor.clj:920)
	at metabase.driver.sql.query_processor$apply_clauses.invoke(query_processor.clj:909)
	at metabase.driver.sql.query_processor$apply_clauses.invokeStatic(query_processor.clj:915)
	at metabase.driver.sql.query_processor$apply_clauses.invoke(query_processor.clj:909)
	at metabase.driver.sql.query_processor$fn__69306$build_honeysql_form__69311$fn__69315.invoke(query_processor.clj:929)
	at metabase.driver.sql.query_processor$fn__69306$build_honeysql_form__69311.invoke(query_processor.clj:926)
	at metabase.driver.sql.query_processor$mbql__GT_honeysql.invokeStatic(query_processor.clj:940)
	at metabase.driver.sql.query_processor$mbql__GT_honeysql.invoke(query_processor.clj:938)
	at metabase.driver.sql.query_processor$mbql__GT_native.invokeStatic(query_processor.clj:946)
	at metabase.driver.sql.query_processor$mbql__GT_native.invoke(query_processor.clj:942)
	at metabase.driver.sql$fn__78116.invokeStatic(sql.clj:40)
	at metabase.driver.sql$fn__78116.invoke(sql.clj:38)
	at clojure.lang.MultiFn.invoke(MultiFn.java:234)
	at metabase.query_processor.middleware.mbql_to_native$query__GT_native_form.invokeStatic(mbql_to_native.clj:15)
	at metabase.query_processor.middleware.mbql_to_native$query__GT_native_form.invoke(mbql_to_native.clj:10)
	at metabase.query_processor.middleware.mbql_to_native$mbql__GT_native$fn__47457.invoke(mbql_to_native.clj:23)
	at metabase.query_processor.middleware.check_features$check_features$fn__46732.invoke(check_features.clj:42)
	at metabase.query_processor.middleware.optimize_datetime_filters$optimize_datetime_filters$fn__47622.invoke(optimize_datetime_filters.clj:133)
	at metabase.query_processor.middleware.auto_parse_filter_values$auto_parse_filter_values$fn__45533.invoke(auto_parse_filter_values.clj:44)
	at metabase.query_processor.middleware.wrap_value_literals$wrap_value_literals$fn__49188.invoke(wrap_value_literals.clj:149)
	at metabase.query_processor.middleware.annotate$add_column_info$fn__45295.invoke(annotate.clj:575)
	at metabase.query_processor.middleware.permissions$check_query_permissions$fn__46607.invoke(permissions.clj:70)
	at metabase.query_processor.middleware.pre_alias_aggregations$pre_alias_aggregations$fn__48140.invoke(pre_alias_aggregations.clj:40)
	at metabase.query_processor.middleware.cumulative_aggregations$handle_cumulative_aggregations$fn__46805.invoke(cumulative_aggregations.clj:61)
	at metabase.query_processor.middleware.resolve_joined_fields$resolve_joined_fields$fn__48377.invoke(resolve_joined_fields.clj:36)
	at metabase.query_processor.middleware.resolve_joins$resolve_joins$fn__48696.invoke(resolve_joins.clj:183)
	at metabase.query_processor.middleware.add_implicit_joins$add_implicit_joins$fn__41020.invoke(add_implicit_joins.clj:254)
	at metabase.query_processor.middleware.large_int_id$convert_id_to_string$fn__47418.invoke(large_int_id.clj:44)
	at metabase.query_processor.middleware.limit$limit$fn__47443.invoke(limit.clj:38)
	at metabase.query_processor.middleware.format_rows$format_rows$fn__47398.invoke(format_rows.clj:84)
	at metabase.query_processor.middleware.desugar$desugar$fn__46871.invoke(desugar.clj:22)
	at metabase.query_processor.middleware.binning$update_binning_strategy$fn__45892.invoke(binning.clj:229)
	at metabase.query_processor.middleware.resolve_fields$resolve_fields$fn__46409.invoke(resolve_fields.clj:24)
	at metabase.query_processor.middleware.add_dimension_projections$add_remapping$fn__40564.invoke(add_dimension_projections.clj:318)
	at metabase.query_processor.middleware.add_implicit_clauses$add_implicit_clauses$fn__40771.invoke(add_implicit_clauses.clj:141)
	at metabase.query_processor.middleware.add_source_metadata$add_source_metadata_for_source_queries$fn__41169.invoke(add_source_metadata.clj:105)
	at metabase.query_processor.middleware.reconcile_breakout_and_order_by_bucketing$reconcile_breakout_and_order_by_bucketing$fn__48337.invoke(reconcile_breakout_and_order_by_bucketing.clj:98)
	at metabase.query_processor.middleware.auto_bucket_datetimes$auto_bucket_datetimes$fn__45480.invoke(auto_bucket_datetimes.clj:125)
	at metabase.query_processor.middleware.resolve_source_table$resolve_source_tables$fn__46456.invoke(resolve_source_table.clj:46)
	at metabase.query_processor.middleware.parameters$substitute_parameters$fn__48122.invoke(parameters.clj:114)
	at metabase.query_processor.middleware.resolve_referenced$resolve_referenced_card_resources$fn__46508.invoke(resolve_referenced.clj:80)
	at metabase.query_processor.middleware.expand_macros$expand_macros$fn__47127.invoke(expand_macros.clj:158)
	at metabase.query_processor.middleware.add_timezone_info$add_timezone_info$fn__41200.invoke(add_timezone_info.clj:15)
	at metabase.query_processor.middleware.splice_params_in_response$splice_params_in_response$fn__49058.invoke(splice_params_in_response.clj:32)
	at metabase.query_processor.middleware.resolve_database_and_driver$resolve_database_and_driver$fn__48348$fn__48352.invoke(resolve_database_and_driver.clj:33)
	at metabase.driver$do_with_driver.invokeStatic(driver.clj:61)
	at metabase.driver$do_with_driver.invoke(driver.clj:57)
	at metabase.query_processor.middleware.resolve_database_and_driver$resolve_database_and_driver$fn__48348.invoke(resolve_database_and_driver.clj:27)
	at metabase.query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__47345.invoke(fetch_source_query.clj:267)
	at metabase.query_processor.middleware.store$initialize_store$fn__49067$fn__49068.invoke(store.clj:11)
	at metabase.query_processor.store$do_with_store.invokeStatic(store.clj:44)
	at metabase.query_processor.store$do_with_store.invoke(store.clj:40)
	at metabase.query_processor.middleware.store$initialize_store$fn__49067.invoke(store.clj:10)
	at metabase.query_processor.middleware.cache$maybe_return_cached_results$fn__46385.invoke(cache.clj:214)
	at metabase.query_processor.middleware.validate$validate_query$fn__49076.invoke(validate.clj:10)
	at metabase.query_processor.middleware.normalize_query$normalize$fn__47470.invoke(normalize_query.clj:22)
	at metabase.query_processor.middleware.add_rows_truncated$add_rows_truncated$fn__41038.invoke(add_rows_truncated.clj:36)
	at metabase.query_processor.middleware.results_metadata$record_and_return_metadata_BANG_$fn__49043.invoke(results_metadata.clj:143)
	at metabase.query_processor.reducible$async_qp$qp_STAR___39827$thunk__39828.invoke(reducible.clj:103)
	at metabase.query_processor.reducible$async_qp$qp_STAR___39827.invoke(reducible.clj:109)
	at metabase.query_processor.reducible$sync_qp$qp_STAR___39836$fn__39839.invoke(reducible.clj:135)
	at metabase.query_processor.reducible$sync_qp$qp_STAR___39836.invoke(reducible.clj:134)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$apply.invoke(core.clj:660)
	at metabase.query_processor$process_query.invokeStatic(query_processor.clj:146)
	at metabase.query_processor$process_query.doInvoke(query_processor.clj:140)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at clojure.lang.Var.invoke(Var.java:388)
	at metabase.db.metadata_queries$fn__57484$table_rows_sample__57493$fn__57496.invoke(metadata_queries.clj:142)
	at metabase.db.metadata_queries$fn__57484$table_rows_sample__57493.invoke(metadata_queries.clj:129)
	at metabase.sync.analyze.fingerprint$fn__57549$fingerprint_table_BANG___57554$fn__57555.invoke(fingerprint.clj:69)
	at metabase.sync.analyze.fingerprint$fn__57549$fingerprint_table_BANG___57554.invoke(fingerprint.clj:49)
	at metabase.sync.analyze.fingerprint$fn__57724$fingerprint_fields_BANG___57729$fn__57730$fn__57731.invoke(fingerprint.clj:173)
	at metabase.sync.util$do_with_error_handling.invokeStatic(util.clj:149)
	at metabase.sync.util$do_with_error_handling.invoke(util.clj:142)
	at metabase.sync.analyze.fingerprint$fn__57724$fingerprint_fields_BANG___57729$fn__57730.invoke(fingerprint.clj:171)
	at metabase.sync.analyze.fingerprint$fn__57724$fingerprint_fields_BANG___57729.invoke(fingerprint.clj:167)
	at metabase.sync.analyze.fingerprint$fn__57752$fingerprint_fields_for_db_BANG___57757$fn__57758$fn__57759$iter__57760__57764$fn__57765$fn__57766.invoke(fingerprint.clj:191)
	at metabase.sync.analyze.fingerprint$fn__57752$fingerprint_fields_for_db_BANG___57757$fn__57758$fn__57759$iter__57760__57764$fn__57765.invoke(fingerprint.clj:188)
	at clojure.lang.LazySeq.sval(LazySeq.java:42)
	at clojure.lang.LazySeq.seq(LazySeq.java:51)
	at clojure.lang.ChunkedCons.chunkedNext(ChunkedCons.java:59)
	at clojure.core$chunk_next.invokeStatic(core.clj:708)
	at clojure.core$reduce1.invokeStatic(core.clj:942)
	at clojure.core$reduce1.invokeStatic(core.clj:934)
	at clojure.core$merge_with.invokeStatic(core.clj:3059)
	at clojure.core$merge_with.doInvoke(core.clj:3051)
	at clojure.lang.RestFn.applyTo(RestFn.java:139)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$apply.invoke(core.clj:660)
	at metabase.sync.analyze.fingerprint$fn__57752$fingerprint_fields_for_db_BANG___57757$fn__57758$fn__57759.invoke(fingerprint.clj:188)
	at metabase.query_processor.store$do_with_store.invokeStatic(store.clj:46)
	at metabase.query_processor.store$do_with_store.invoke(store.clj:40)
	at metabase.sync.analyze.fingerprint$fn__57752$fingerprint_fields_for_db_BANG___57757$fn__57758.invoke(fingerprint.clj:185)
	at metabase.sync.analyze.fingerprint$fn__57752$fingerprint_fields_for_db_BANG___57757.invoke(fingerprint.clj:179)
	at metabase.sync.analyze$make_analyze_steps$fn__57898.invoke(analyze.clj:106)
	at metabase.sync.util$fn__44054$run_step_with_metadata__44059$fn__44063$fn__44065.invoke(util.clj:345)
	at metabase.sync.util$with_start_and_finish_logging_STAR_.invokeStatic(util.clj:102)
	at metabase.sync.util$with_start_and_finish_logging_STAR_.invoke(util.clj:96)
	at metabase.sync.util$with_start_and_finish_debug_logging.invokeStatic(util.clj:119)
	at metabase.sync.util$with_start_and_finish_debug_logging.invoke(util.clj:116)
	at metabase.sync.util$fn__44054$run_step_with_metadata__44059$fn__44063.invoke(util.clj:342)
	at metabase.sync.util$fn__44054$run_step_with_metadata__44059.invoke(util.clj:337)
	at metabase.sync.util$fn__44246$run_sync_operation__44251$fn__44252$fn__44253.invoke(util.clj:430)
	at clojure.core$mapv$fn__8445.invoke(core.clj:6912)
	at clojure.lang.PersistentVector.reduce(PersistentVector.java:343)
	at clojure.core$reduce.invokeStatic(core.clj:6827)
	at clojure.core$mapv.invokeStatic(core.clj:6903)
	at clojure.core$mapv.invoke(core.clj:6903)
	at metabase.sync.util$fn__44246$run_sync_operation__44251$fn__44252.invoke(util.clj:430)
	at metabase.sync.util$fn__44246$run_sync_operation__44251.invoke(util.clj:424)
	at metabase.sync.analyze$fn__57910$analyze_db_BANG___57915$fn__57916$fn__57917.invoke(analyze.clj:123)
	at metabase.sync.util$do_with_error_handling.invokeStatic(util.clj:149)
	at metabase.sync.util$do_with_error_handling.invoke(util.clj:142)
	at metabase.sync.util$do_with_error_handling.invokeStatic(util.clj:145)
	at metabase.sync.util$do_with_error_handling.invoke(util.clj:142)
	at clojure.core$partial$fn__5839.invoke(core.clj:2623)
	at metabase.driver$fn__22483.invokeStatic(driver.clj:550)
	at metabase.driver$fn__22483.invoke(driver.clj:550)
	at clojure.lang.MultiFn.invoke(MultiFn.java:239)
	at metabase.sync.util$sync_in_context$fn__43966.invoke(util.clj:138)
	at metabase.sync.util$with_db_logging_disabled$fn__43963.invoke(util.clj:129)
	at metabase.sync.util$with_start_and_finish_logging_STAR_.invokeStatic(util.clj:102)
	at metabase.sync.util$with_start_and_finish_logging_STAR_.invoke(util.clj:96)
	at metabase.sync.util$with_start_and_finish_logging$fn__43952.invoke(util.clj:114)
	at metabase.sync.util$with_sync_events$fn__43947.invoke(util.clj:88)
	at metabase.sync.util$with_duplicate_ops_prevented$fn__43938.invoke(util.clj:67)
	at metabase.sync.util$do_sync_operation.invokeStatic(util.clj:164)
	at metabase.sync.util$do_sync_operation.invoke(util.clj:161)
	at metabase.sync.analyze$fn__57910$analyze_db_BANG___57915$fn__57916.invoke(analyze.clj:120)
	at metabase.sync.analyze$fn__57910$analyze_db_BANG___57915.invoke(analyze.clj:115)
	at metabase.task.sync_databases$sync_and_analyze_database_BANG_.invokeStatic(sync_databases.clj:52)
	at metabase.task.sync_databases$sync_and_analyze_database_BANG_.invoke(sync_databases.clj:40)
	at metabase.task.sync_databases.SyncAndAnalyzeDatabase.execute(sync_databases.clj:55)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)

SQL query:
SELECT
created_at,
modified_at,
property_change_request_id,
request_type,
CASE
WHEN approved_by_id IS NULL THEN 0
ELSE approved_by_id
END
AS approved_by_id,,
company_id,
property_id,
requested_by_id,
status
FROM property_requests

Please let me know if you need anything.

@aalap Check your query - AS approved_by_id,, <-- there's two commas
Latest release is 0.39.2: https://github.com/metabase/metabase/releases/latest

Hey @flamber,
Sorry by mistake I posted that, but the original query is as below:
SELECT
created_at,
modified_at,
property_change_request_id,
request_type,
CASE
WHEN approved_by_id IS NULL THEN 0
ELSE approved_by_id
END
AS approved_by_id,
company_id,
property_id,
requested_by_id,
status
FROM property_change_requests

@aalap Make sure you're using a driver version that is compatible with the version of Metabase.

1 Like

@flamber,
Driver details:
info:
name: Metabase Athena Driver
version: 0.1.1-athena-jdbc-2.0.7
description: Allows Metabase to connect to AWS Athena databases. Community Supported driver.
driver:
name: athena
display-name: Athena
lazy-load: true
parent: sql-jdbc

And Metabase version:
v0.37.3 (Built on 2020-12-03)

Should I upgrade the version to latest one?
Thanks

@aalap There has been many updates to both Metabase and the driver, so yes, try. Remember to backup first, so you can revert if something is causing worse problems.