Skip to content

evidence tables / evidence schema fail on BigQuery: rows is a reserved keyword #3331

Description

@saghatelian

Summary

evidence tables and evidence schema always fail against a BigQuery direct connector. The introspection query aliases a column to rows, which is a reserved keyword in BigQuery, so the query never parses.

Environment

  • Evidence CLI v0.9.3 (evidence upgrade confirms this is the latest)
  • macOS 15.6 / arm64
  • BigQuery direct connector via local connection.yaml (not logged in to Studio)

Steps to reproduce

connection.yaml:

type: bigquery
project: my-project
keyfile: ./sa-key.json
location: EU
dataset: my_dataset
datasets:
  - my_dataset
evidence tables

Actual

Syntax error: Unexpected keyword ROWS at [1:66]

evidence schema fails identically.

Cause

The CLI builds this query for the bigquery case:

SELECT table_id AS name, dataset_id AS schema_name, row_count AS rows
FROM `<project>`.`<dataset>`.__TABLES__ ORDER BY table_id

rows is a BigQuery reserved keyword. Character 66 is exactly where rows begins.

Confirmed by running both forms by hand:

$ evidence query "SELECT table_id AS name, dataset_id AS schema_name, row_count AS rows FROM \`p\`.\`d\`.__TABLES__"
Syntax error: Unexpected keyword ROWS at [1:81]

$ evidence query "SELECT table_id AS name, dataset_id AS schema_name, row_count AS \`rows\` FROM \`p\`.\`d\`.__TABLES__ LIMIT 3"
{"name":"ad_group","schema_name":"my_dataset","rows":0}
...

Suggested fix

Backtick the alias in the BigQuery branch:

SELECT table_id AS name, dataset_id AS schema_name, row_count AS `rows` FROM ...

The ClickHouse branch (total_rows AS rows) is fine — ClickHouse does not reserve rows.

Impact

Low severity but no workaround: the query is compiled into the CLI binary, so it cannot be overridden from config. Page rendering is unaffected — only the table-listing commands and anything downstream of them.

Possibly related

__TABLES__ only reflects tables and views with a materialized row_count; views report 0. If the intent is to list views too, INFORMATION_SCHEMA.TABLES may be a better source.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions