Skip to content

Commit

Permalink
chore(deps): update dependency sqlglot to v24 (#14)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency sqlglot to v24

* fix: add dataframe struct support that used to be in sqlglot

* fix: add missing ensure column mapping

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: eakmanrq <6326532+eakmanrq@users.noreply.github.com>
  • Loading branch information
renovate[bot] and eakmanrq authored May 22, 2024
1 parent 221fcba commit 0b1acd2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
python_requires=">=3.8",
install_requires=[
"prettytable<3.11.0",
"sqlglot>=23.14.0,<23.18",
"sqlglot>=24.0.0,<24.1",
],
extras_require={
"bigquery": [
Expand Down
3 changes: 2 additions & 1 deletion sqlframe/base/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from sqlframe.base.decorators import normalize
from sqlframe.base.exceptions import TableSchemaError
from sqlframe.base.util import to_schema
from sqlframe.base.util import ensure_column_mapping, to_schema

if t.TYPE_CHECKING:
from sqlglot.schema import ColumnMapping
Expand Down Expand Up @@ -82,6 +82,7 @@ def add_table(
raise TableSchemaError(
"This session does not have access to a catalog that can lookup column information. See docs for explicitly defining columns or using a session that can automatically determine this."
)
column_mapping = ensure_column_mapping(column_mapping) # type: ignore
self._schema.add_table(table, column_mapping, dialect=self.session.input_dialect)

@normalize(["dbName"])
Expand Down
2 changes: 2 additions & 0 deletions sqlframe/base/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def ensure_column_mapping(schema: t.Union[str, StructType]) -> t.Dict:
}
# TODO: Make a protocol with a `simpleString` attribute as what it looks for instead of the actual
# `StructType` object.
elif hasattr(schema, "simpleString"):
return {struct_field.name: struct_field.dataType.simpleString() for struct_field in schema}
return sqlglot_ensure_column_mapping(schema) # type: ignore


Expand Down

0 comments on commit 0b1acd2

Please sign in to comment.