Skip to content

Syntax Error in BigQuery While Retrieving Columns that Start with a Number #4688

Description

@nishantgaurav-dev

Expected Behavior

We have a feature view like this:

mbr_visits_fv_v1 = FeatureView(
	...
    schema=[
        Field(name="7_days_visits", dtype=Int64),
        Field(name="30_daysvisits", dtype=Int64),
    ],
    source=mbr_visits_bq_ds_v1
    ...
)

While querying this view as offline features I am expecting a data-frame containing desired columns without any error.

Current Behavior

Feast SDK is giving error like:
google.api_core.exceptions.BadRequest: 400 Syntax error: Missing whitespace between literal and alias at ...

I have printed some logs and observed that the generated BQ query contains a segment like this:

SELECT
  event_timestamp as event_timestamp,
  mbr_id AS mbr_id,
  7_days_visits as 7_days_visits
  30_days_visits as 30_days_visits
FROM `myproj.my_dataset.mbr_visits`
WHERE event_timestamp <= '2024-06-27T00:00:00'

This is incorrect BQ query.

It should be like this:

SELECT
  event_timestamp as event_timestamp,
  mbr_id AS mbr_id,
  `7_days_visits` as `7_days_visits`
  `30_days_visits` as `30_days_visits`
FROM `myproj.my_dataset.mbr_visits`
WHERE event_timestamp <= '2024-06-27T00:00:00'

The BQ expects that if a queried column starts with a number, the name should be enclosed in backtick (`) chars.

Steps to reproduce

Try querying a feature view with column name starting with number and use BigQuery data source.

Specifications

  • Version: 0.34.1
  • Platform: Mac
  • Subsystem:

Possible Solution

Enclose all the BQ column names with backtick (`) chars. It will reduce the readability a little bit, but won't cause any performance impact.

Activity

  1. changed the title [-]Syntactically incorrect BQ query while retrieving columns with number in the begining.[/-] [+]Syntax Error in BigQuery While Retrieving Columns that Start with a Number[/+] on Oct 25, 2024
  2. tmihalac commented on Oct 28, 2024

    @tmihalac
    Contributor

    "While querying this view as offline features I am expecting a data-frame containing desired columns without any error."
    Can you also explain how did you query this view, which api and also a stack trace of the exception will be helpful

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions