Skip to content

Commit

Permalink
feat: add execution dialect name (eakmanrq#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
eakmanrq authored Jan 30, 2025
1 parent ec19019 commit 5b2b97e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sqlframe/base/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ def __init__(
if not getattr(self, "schema", None) or schema:
self._schema = schema

# https://github.com/eakmanrq/sqlframe/issues/262
@property
def execution_dialect_name(self) -> str:
return self.execution_dialect.__class__.__name__.lower()

@property
def read(self) -> READER:
return self._reader(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ def test_session_from_config():
session = BigQuerySession.builder.config("default_dataset", "sqlframe.db1").getOrCreate()
columns = session.catalog.get_columns("db1.test_table")
assert columns == {"cola": exp.DataType.build("BIGINT"), "colb": exp.DataType.build("TEXT")}
assert session.execution_dialect_name == "bigquery"
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ def test_session_from_config(cleanup_connector: DatabricksConnection):
"cola": exp.DataType.build("INT", dialect=session.output_dialect),
"colb": exp.DataType.build("STRING", dialect=session.output_dialect),
}
assert session.execution_dialect_name == "databricks"
1 change: 1 addition & 0 deletions tests/integration/engines/duck/test_duckdb_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ def test_session_from_config():
session = DuckDBSession.builder.config("sqlframe.conn", conn).getOrCreate()
columns = session.catalog.get_columns("test_table")
assert columns == {"cola": exp.DataType.build("INT"), "colb": exp.DataType.build("TEXT")}
assert session.execution_dialect_name == "duckdb"
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ def test_session_from_config(function_scoped_postgres):
"cola": exp.DataType.build("INT", dialect=session.output_dialect),
"colb": exp.DataType.build("STRING", dialect=session.output_dialect),
}
assert session.execution_dialect_name == "postgres"
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ def test_session_from_config(cleanup_connector: RedshiftConnection):
"cola": exp.DataType.build("INT", dialect=session.output_dialect),
"colb": exp.DataType.build("STRING", dialect=session.output_dialect),
}
assert session.execution_dialect_name == "redshift"
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ def test_session_from_config(cleanup_connector: SnowflakeConnection):
"cola": exp.DataType.build("DECIMAL(38, 0)", dialect=session.output_dialect),
"colb": exp.DataType.build("TEXT", dialect=session.output_dialect),
}
assert session.execution_dialect_name == "snowflake"

0 comments on commit 5b2b97e

Please sign in to comment.