From 2b921f817343bcb7b62656cf57e741580aeafff4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 6 Jun 2024 09:35:40 -0700 Subject: [PATCH] fix(deps): update dependency sqlglot to v25 (#9316) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Phillip Cloud <417981+cpcloud@users.noreply.github.com> --- ibis/backends/datafusion/compiler.py | 2 +- ibis/backends/duckdb/__init__.py | 8 +++----- ibis/backends/duckdb/compiler.py | 20 ++++++++++++++------ ibis/backends/exasol/__init__.py | 2 +- ibis/backends/mysql/__init__.py | 2 -- ibis/backends/mysql/compiler.py | 14 ++++++++++---- ibis/backends/oracle/__init__.py | 4 ++-- ibis/backends/postgres/__init__.py | 12 ++++++------ ibis/backends/postgres/compiler.py | 10 ++++++---- ibis/backends/sqlite/__init__.py | 12 ++++++------ ibis/backends/sqlite/compiler.py | 10 ++++++---- poetry.lock | 8 ++++---- pyproject.toml | 2 +- requirements-dev.txt | 2 +- 14 files changed, 61 insertions(+), 47 deletions(-) diff --git a/ibis/backends/datafusion/compiler.py b/ibis/backends/datafusion/compiler.py index c186a252edfd..1a338582487f 100644 --- a/ibis/backends/datafusion/compiler.py +++ b/ibis/backends/datafusion/compiler.py @@ -136,7 +136,7 @@ def visit_Cast(self, op, *, arg, to): return self.cast(arg, to) def visit_Arbitrary(self, op, *, arg, where): - cond = ~arg.is_(None) + cond = ~arg.is_(NULL) if where is not None: cond &= where return self.agg.first_value(arg, where=cond) diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index 0380bf3206b9..64253fda183a 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -1008,12 +1008,10 @@ def list_tables( .from_(sg.table("tables", db="information_schema")) .distinct() .where( - C.table_catalog.eq(catalog).or_( - C.table_catalog.eq(sge.convert("temp")) - ), - C.table_schema.eq(database), + C.table_catalog.isin(sge.convert(catalog), sge.convert("temp")), + C.table_schema.eq(sge.convert(database)), ) - .sql(self.name, pretty=True) + .sql(self.dialect) ) out = self.con.execute(sql).fetch_arrow_table() diff --git a/ibis/backends/duckdb/compiler.py b/ibis/backends/duckdb/compiler.py index 2cc789ea360c..54c53b892117 100644 --- a/ibis/backends/duckdb/compiler.py +++ b/ibis/backends/duckdb/compiler.py @@ -238,21 +238,21 @@ def visit_MapMerge(self, op, *, left, right): def visit_ToJSONMap(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("OBJECT"), + self.f.json_type(arg).eq(sge.convert("OBJECT")), self.cast(self.cast(arg, dt.json), op.dtype), NULL, ) def visit_ToJSONArray(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("ARRAY"), + self.f.json_type(arg).eq(sge.convert("ARRAY")), self.cast(self.cast(arg, dt.json), op.dtype), NULL, ) def visit_UnwrapJSONString(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("VARCHAR"), + self.f.json_type(arg).eq(sge.convert("VARCHAR")), self.f.json_extract_string(arg, "$"), NULL, ) @@ -260,18 +260,26 @@ def visit_UnwrapJSONString(self, op, *, arg): def visit_UnwrapJSONInt64(self, op, *, arg): arg_type = self.f.json_type(arg) return self.if_( - arg_type.isin("UBIGINT", "BIGINT"), self.cast(arg, op.dtype), NULL + arg_type.isin(sge.convert("UBIGINT"), sge.convert("BIGINT")), + self.cast(arg, op.dtype), + NULL, ) def visit_UnwrapJSONFloat64(self, op, *, arg): arg_type = self.f.json_type(arg) return self.if_( - arg_type.isin("UBIGINT", "BIGINT", "DOUBLE"), self.cast(arg, op.dtype), NULL + arg_type.isin( + sge.convert("UBIGINT"), sge.convert("BIGINT"), sge.convert("DOUBLE") + ), + self.cast(arg, op.dtype), + NULL, ) def visit_UnwrapJSONBoolean(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("BOOLEAN"), self.cast(arg, op.dtype), NULL + self.f.json_type(arg).eq(sge.convert("BOOLEAN")), + self.cast(arg, op.dtype), + NULL, ) def visit_ArrayConcat(self, op, *, arg): diff --git a/ibis/backends/exasol/__init__.py b/ibis/backends/exasol/__init__.py index e9b0186b0e71..0eb1afc1664a 100644 --- a/ibis/backends/exasol/__init__.py +++ b/ibis/backends/exasol/__init__.py @@ -50,7 +50,7 @@ def version(self) -> str: query = ( sg.select("param_value") .from_(sg.table("EXA_METADATA", catalog="SYS")) - .where(C.param_name.eq("databaseProductVersion")) + .where(C.param_name.eq(sge.convert("databaseProductVersion"))) ) with self._safe_raw_sql(query) as result: [(version,)] = result.fetchall() diff --git a/ibis/backends/mysql/__init__.py b/ibis/backends/mysql/__init__.py index bbd0fa79c7f7..917f52fd7015 100644 --- a/ibis/backends/mysql/__init__.py +++ b/ibis/backends/mysql/__init__.py @@ -329,8 +329,6 @@ def list_tables( sg_db.args["quoted"] = False conditions = [C.table_schema.eq(sge.convert(table_loc.sql(self.name)))] - # conditions.append(C.table_schema.eq(table_loc)) - col = "table_name" sql = ( sg.select(col) diff --git a/ibis/backends/mysql/compiler.py b/ibis/backends/mysql/compiler.py index 66e791266c63..f4ce57ec931f 100644 --- a/ibis/backends/mysql/compiler.py +++ b/ibis/backends/mysql/compiler.py @@ -336,22 +336,28 @@ def visit_TimestampAdd(self, op, *, left, right): def visit_UnwrapJSONString(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("STRING"), self.f.json_unquote(arg), NULL + self.f.json_type(arg).eq(sge.convert("STRING")), + self.f.json_unquote(arg), + NULL, ) def visit_UnwrapJSONInt64(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("INTEGER"), self.cast(arg, op.dtype), NULL + self.f.json_type(arg).eq(sge.convert("INTEGER")), + self.cast(arg, op.dtype), + NULL, ) def visit_UnwrapJSONFloat64(self, op, *, arg): return self.if_( - self.f.json_type(arg).isin("DOUBLE", "INTEGER"), + self.f.json_type(arg).isin(sge.convert("DOUBLE"), sge.convert("INTEGER")), self.cast(arg, op.dtype), NULL, ) def visit_UnwrapJSONBoolean(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("BOOLEAN"), self.if_(arg.eq("true"), 1, 0), NULL + self.f.json_type(arg).eq(sge.convert("BOOLEAN")), + self.if_(arg.eq(sge.convert("true")), 1, 0), + NULL, ) diff --git a/ibis/backends/oracle/__init__.py b/ibis/backends/oracle/__init__.py index 2f1dc277b8b8..1107a5bc2cbc 100644 --- a/ibis/backends/oracle/__init__.py +++ b/ibis/backends/oracle/__init__.py @@ -550,10 +550,10 @@ def transformer(node): C.data_type, C.data_precision, C.data_scale, - C.nullable.eq("Y"), + C.nullable.eq(sge.convert("Y")), ) .from_("all_tab_columns") - .where(C.table_name.eq(name)) + .where(C.table_name.eq(sge.convert(name))) .order_by(C.column_id) .sql(dialect) ) diff --git a/ibis/backends/postgres/__init__.py b/ibis/backends/postgres/__init__.py index bdd8f2467967..1deaa654b895 100644 --- a/ibis/backends/postgres/__init__.py +++ b/ibis/backends/postgres/__init__.py @@ -352,11 +352,11 @@ def list_tables( if (db := table_loc.args["db"]) is not None: db.args["quoted"] = False db = db.sql(dialect=self.name) - conditions.append(C.table_schema.eq(db)) + conditions.append(C.table_schema.eq(sge.convert(db))) if (catalog := table_loc.args["catalog"]) is not None: catalog.args["quoted"] = False catalog = catalog.sql(dialect=self.name) - conditions.append(C.table_catalog.eq(catalog)) + conditions.append(C.table_catalog.eq(sge.convert(catalog))) sql = ( sg.select("table_name") @@ -385,7 +385,7 @@ def _fetch_temp_tables(self): sg.select("table_name") .from_(sg.table("tables", db="information_schema")) .distinct() - .where(C.table_type.eq("LOCAL TEMPORARY")) + .where(C.table_type.eq(sge.convert("LOCAL TEMPORARY"))) .sql(self.dialect) ) @@ -434,7 +434,7 @@ def function(self, name: str, *, database: str | None = None) -> Callable: p = ColGen(table="p") f = self.compiler.f - predicates = [p.proname.eq(name)] + predicates = [p.proname.eq(sge.convert(name))] if database is not None: predicates.append(n.nspname.rlike(sge.convert(f"^({database})$"))) @@ -585,8 +585,8 @@ def get_schema( .where( a.attnum > 0, sg.not_(a.attisdropped), - n.nspname.eq(database) if database is not None else TRUE, - c.relname.eq(name), + n.nspname.eq(sge.convert(database)) if database is not None else TRUE, + c.relname.eq(sge.convert(name)), ) .order_by(a.attnum) ) diff --git a/ibis/backends/postgres/compiler.py b/ibis/backends/postgres/compiler.py index 2e74f380ffc9..496119949689 100644 --- a/ibis/backends/postgres/compiler.py +++ b/ibis/backends/postgres/compiler.py @@ -319,7 +319,7 @@ def visit_StructField(self, op, *, arg, field): def visit_UnwrapJSONString(self, op, *, arg): return self.if_( - self.f.json_typeof(arg).eq("string"), + self.f.json_typeof(arg).eq(sge.convert("string")), self.f.json_extract_path_text( arg, # this is apparently how you pass in no additional arguments to @@ -336,7 +336,7 @@ def visit_UnwrapJSONInt64(self, op, *, arg): arg, sge.Var(this="VARIADIC ARRAY[]::TEXT[]") ) return self.if_( - self.f.json_typeof(arg).eq("number"), + self.f.json_typeof(arg).eq(sge.convert("number")), self.cast( self.if_(self.f.regexp_like(text, r"^\d+$", "g"), text, NULL), op.dtype, @@ -349,12 +349,14 @@ def visit_UnwrapJSONFloat64(self, op, *, arg): arg, sge.Var(this="VARIADIC ARRAY[]::TEXT[]") ) return self.if_( - self.f.json_typeof(arg).eq("number"), self.cast(text, op.dtype), NULL + self.f.json_typeof(arg).eq(sge.convert("number")), + self.cast(text, op.dtype), + NULL, ) def visit_UnwrapJSONBoolean(self, op, *, arg): return self.if_( - self.f.json_typeof(arg).eq("boolean"), + self.f.json_typeof(arg).eq(sge.convert("boolean")), self.cast( self.f.json_extract_path_text( arg, sge.Var(this="VARIADIC ARRAY[]::TEXT[]") diff --git a/ibis/backends/sqlite/__init__.py b/ibis/backends/sqlite/__init__.py index 6989bff9e3da..960729ea894d 100644 --- a/ibis/backends/sqlite/__init__.py +++ b/ibis/backends/sqlite/__init__.py @@ -145,14 +145,14 @@ def list_tables( sg.select("name") .from_(F.pragma_table_list()) .where( - C.schema.eq(database), - C.type.isin("table", "view"), + C.schema.eq(sge.convert(database)), + C.type.isin(sge.convert("table"), sge.convert("view")), ~( C.name.isin( - "sqlite_schema", - "sqlite_master", - "sqlite_temp_schema", - "sqlite_temp_master", + sge.convert("sqlite_schema"), + sge.convert("sqlite_master"), + sge.convert("sqlite_temp_schema"), + sge.convert("sqlite_temp_master"), ) ), ) diff --git a/ibis/backends/sqlite/compiler.py b/ibis/backends/sqlite/compiler.py index c2232a885669..50cab3700728 100644 --- a/ibis/backends/sqlite/compiler.py +++ b/ibis/backends/sqlite/compiler.py @@ -223,19 +223,21 @@ def _visit_arg_reduction(self, func, op, *, arg, key, where): def visit_UnwrapJSONString(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("text"), self.f.json_extract_scalar(arg, "$"), NULL + self.f.json_type(arg).eq(sge.convert("text")), + self.f.json_extract_scalar(arg, "$"), + NULL, ) def visit_UnwrapJSONInt64(self, op, *, arg): return self.if_( - self.f.json_type(arg).eq("integer"), + self.f.json_type(arg).eq(sge.convert("integer")), self.cast(self.f.json_extract_scalar(arg, "$"), op.dtype), NULL, ) def visit_UnwrapJSONFloat64(self, op, *, arg): return self.if_( - self.f.json_type(arg).isin("integer", "real"), + self.f.json_type(arg).isin(sge.convert("integer"), sge.convert("real")), self.cast(self.f.json_extract_scalar(arg, "$"), op.dtype), NULL, ) @@ -244,7 +246,7 @@ def visit_UnwrapJSONBoolean(self, op, *, arg): return self.if_( # isin doesn't work here, with a strange error from sqlite about a # misused row value - self.f.json_type(arg).isin("true", "false"), + self.f.json_type(arg).isin(sge.convert("true"), sge.convert("false")), self.cast(self.f.json_extract_scalar(arg, "$"), dt.int64), NULL, ) diff --git a/poetry.lock b/poetry.lock index c2dfe8f27971..a1f19db948bd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -7074,13 +7074,13 @@ sqlcipher = ["sqlcipher3_binary"] [[package]] name = "sqlglot" -version = "24.1.0" +version = "25.0.0" description = "An easily customizable SQL parser and transpiler" optional = false python-versions = ">=3.7" files = [ - {file = "sqlglot-24.1.0-py3-none-any.whl", hash = "sha256:16128fd54c0fafe1477bca83ec0ac97bee3a2b577d321cea8ebc9d35963027a3"}, - {file = "sqlglot-24.1.0.tar.gz", hash = "sha256:e238a716edae33d83f8301d7ef0836e8ad43597e27c9cc25ed56a0cd5b12bd05"}, + {file = "sqlglot-25.0.0-py3-none-any.whl", hash = "sha256:edd9db3c56f1584130cbd019e03df8df1322d92b68870dc7e7d56df76d7eda97"}, + {file = "sqlglot-25.0.0.tar.gz", hash = "sha256:7055e2e81f68e7f3ce58621051841ce9aa24bc25862674436f94b80625591361"}, ] [package.extras] @@ -8089,4 +8089,4 @@ visualization = ["graphviz"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "9922c5841389b4b48c10abd58da292e7291910bad1286b72e86f2f2be79f4a99" +content-hash = "3613d324a066d1a405963af828ebbcf31f2f9b34584c42e583aa177bbc39b2f2" diff --git a/pyproject.toml b/pyproject.toml index fa28015eec2f..dbfbc56187df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ pyarrow-hotfix = ">=0.4,<1" python-dateutil = ">=2.8.2,<3" pytz = ">=2022.7" rich = ">=12.4.4,<14" -sqlglot = ">=23.4,<24.2" +sqlglot = ">=23.4,<25.1" toolz = ">=0.11,<1" typing-extensions = ">=4.3.0,<5" black = { version = ">=22.1.0,<25", optional = true } diff --git a/requirements-dev.txt b/requirements-dev.txt index d9cf1e0dc99f..e8d19b4b38aa 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -275,7 +275,7 @@ sortedcontainers==2.4.0 ; python_version >= "3.10" and python_version < "4.0" soupsieve==2.5 ; python_version >= "3.10" and python_version < "3.13" sphobjinv==2.3.1.1 ; python_version >= "3.10" and python_version < "3.13" sqlalchemy==2.0.30 ; python_version >= "3.10" and python_version < "3.13" -sqlglot==24.1.0 ; python_version >= "3.10" and python_version < "4.0" +sqlglot==25.0.0 ; python_version >= "3.10" and python_version < "4.0" stack-data==0.6.3 ; python_version >= "3.10" and python_version < "4.0" statsmodels==0.14.2 ; python_version >= "3.10" and python_version < "3.13" stdlib-list==0.10.0 ; python_version >= "3.10" and python_version < "4.0"