Skip to content

Missing alias in PostgreSQLOfflineStore.pull_all_from_table_or_query() #2954

@ikrizanic

Description

@ikrizanic

Expected Behavior

Call pull_all_from_table_or_query() method and retrieve wanted data from offline store.

Current Behavior

SQL error psycopg2.errors.SyntaxError: subquery in FROM must have an alias

Steps to reproduce

Call pull_all_from_table_or_query() on PostgreSQLOfflineStore, where PostgreSQLSource is initialized with query="SELECT * FROM table_name"

Specifications

  • Version: 0.22.1
  • Platform: x86_64
  • Subsystem: Linux 5.18

Possible Solution

Adding alias in query located in PostgreSQLOfflineStore.pull_all_from_table_or_query(), for example adding AS dummy_alias. This was tested on my use-case and it works as expected, and if it looks ok, I could open a PR with this change.

query = f"""
            SELECT {field_string}
            FROM {from_expression} AS dummy_alias
            WHERE "{timestamp_field}" BETWEEN '{start_date}'::timestamptz AND '{end_date}'::timestamptz
        """

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