From 7c953b909c6fb00fea2c56ef625103224e148578 Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Wed, 25 Sep 2024 11:28:05 -0500 Subject: [PATCH] refactor(sql): don't implement `argmin`/`argmax` on the base compiler --- ibis/backends/sql/compilers/base.py | 2 -- ibis/backends/sql/compilers/druid.py | 2 -- ibis/backends/sql/compilers/exasol.py | 2 -- ibis/backends/sql/compilers/flink.py | 2 -- ibis/backends/sql/compilers/impala.py | 2 -- ibis/backends/sql/compilers/mssql.py | 2 -- ibis/backends/sql/compilers/mysql.py | 2 -- ibis/backends/sql/compilers/oracle.py | 2 -- ibis/backends/sql/compilers/pyspark.py | 2 ++ ibis/backends/sql/compilers/snowflake.py | 2 ++ ibis/backends/sql/compilers/trino.py | 2 ++ 11 files changed, 6 insertions(+), 16 deletions(-) diff --git a/ibis/backends/sql/compilers/base.py b/ibis/backends/sql/compilers/base.py index 921a568d30417..a1becd5bfdab4 100644 --- a/ibis/backends/sql/compilers/base.py +++ b/ibis/backends/sql/compilers/base.py @@ -306,8 +306,6 @@ class SQLGlotCompiler(abc.ABC): ops.All: "bool_and", ops.Any: "bool_or", ops.ApproxCountDistinct: "approx_distinct", - ops.ArgMax: "max_by", - ops.ArgMin: "min_by", ops.ArrayContains: "array_contains", ops.ArrayFlatten: "flatten", ops.ArrayLength: "array_size", diff --git a/ibis/backends/sql/compilers/druid.py b/ibis/backends/sql/compilers/druid.py index 4e2710b399925..6548265b95e34 100644 --- a/ibis/backends/sql/compilers/druid.py +++ b/ibis/backends/sql/compilers/druid.py @@ -25,8 +25,6 @@ class DruidCompiler(SQLGlotCompiler): UNSUPPORTED_OPS = ( ops.ApproxMedian, - ops.ArgMax, - ops.ArgMin, ops.ArrayDistinct, ops.ArrayFilter, ops.ArrayFlatten, diff --git a/ibis/backends/sql/compilers/exasol.py b/ibis/backends/sql/compilers/exasol.py index 38bb88174eb32..f45a52cbffbb2 100644 --- a/ibis/backends/sql/compilers/exasol.py +++ b/ibis/backends/sql/compilers/exasol.py @@ -32,8 +32,6 @@ class ExasolCompiler(SQLGlotCompiler): UNSUPPORTED_OPS = ( ops.AnalyticVectorizedUDF, - ops.ArgMax, - ops.ArgMin, ops.ArrayDistinct, ops.ArrayFilter, ops.ArrayFlatten, diff --git a/ibis/backends/sql/compilers/flink.py b/ibis/backends/sql/compilers/flink.py index 9d9b0a45f69c8..2cbb7163a0340 100644 --- a/ibis/backends/sql/compilers/flink.py +++ b/ibis/backends/sql/compilers/flink.py @@ -69,8 +69,6 @@ class FlinkCompiler(SQLGlotCompiler): UNSUPPORTED_OPS = ( ops.AnalyticVectorizedUDF, ops.ApproxMedian, - ops.ArgMax, - ops.ArgMin, ops.ArrayFlatten, ops.ArrayStringJoin, ops.Correlation, diff --git a/ibis/backends/sql/compilers/impala.py b/ibis/backends/sql/compilers/impala.py index 06269cc4b0de0..fb87f14e9cdb6 100644 --- a/ibis/backends/sql/compilers/impala.py +++ b/ibis/backends/sql/compilers/impala.py @@ -30,8 +30,6 @@ class ImpalaCompiler(SQLGlotCompiler): } UNSUPPORTED_OPS = ( - ops.ArgMax, - ops.ArgMin, ops.ArrayPosition, ops.Array, ops.Covariance, diff --git a/ibis/backends/sql/compilers/mssql.py b/ibis/backends/sql/compilers/mssql.py index 900877c5117a7..aaee60a20cda8 100644 --- a/ibis/backends/sql/compilers/mssql.py +++ b/ibis/backends/sql/compilers/mssql.py @@ -82,8 +82,6 @@ class MSSQLCompiler(SQLGlotCompiler): UNSUPPORTED_OPS = ( ops.ApproxMedian, - ops.ArgMax, - ops.ArgMin, ops.Array, ops.ArrayDistinct, ops.ArrayFlatten, diff --git a/ibis/backends/sql/compilers/mysql.py b/ibis/backends/sql/compilers/mysql.py index 9c2172d482375..ee96b0c95b7db 100644 --- a/ibis/backends/sql/compilers/mysql.py +++ b/ibis/backends/sql/compilers/mysql.py @@ -65,8 +65,6 @@ def POS_INF(self): NEG_INF = POS_INF UNSUPPORTED_OPS = ( ops.ApproxMedian, - ops.ArgMax, - ops.ArgMin, ops.Array, ops.ArrayFlatten, ops.ArrayMap, diff --git a/ibis/backends/sql/compilers/oracle.py b/ibis/backends/sql/compilers/oracle.py index 737a7515001af..5d3daf74c6f97 100644 --- a/ibis/backends/sql/compilers/oracle.py +++ b/ibis/backends/sql/compilers/oracle.py @@ -51,8 +51,6 @@ class OracleCompiler(SQLGlotCompiler): } UNSUPPORTED_OPS = ( - ops.ArgMax, - ops.ArgMin, ops.Array, ops.ArrayFlatten, ops.ArrayMap, diff --git a/ibis/backends/sql/compilers/pyspark.py b/ibis/backends/sql/compilers/pyspark.py index b42ac174fa7ae..5587a5186a76e 100644 --- a/ibis/backends/sql/compilers/pyspark.py +++ b/ibis/backends/sql/compilers/pyspark.py @@ -70,6 +70,8 @@ class PySparkCompiler(SQLGlotCompiler): } SIMPLE_OPS = { + ops.ArgMax: "max_by", + ops.ArgMin: "min_by", ops.ArrayDistinct: "array_distinct", ops.ArrayFlatten: "flatten", ops.ArrayIntersect: "array_intersect", diff --git a/ibis/backends/sql/compilers/snowflake.py b/ibis/backends/sql/compilers/snowflake.py index b0e5e3913cae6..c01c6b79d8855 100644 --- a/ibis/backends/sql/compilers/snowflake.py +++ b/ibis/backends/sql/compilers/snowflake.py @@ -106,6 +106,8 @@ class SnowflakeCompiler(SQLGlotCompiler): SIMPLE_OPS = { ops.All: "min", ops.Any: "max", + ops.ArgMax: "max_by", + ops.ArgMin: "min_by", ops.ArrayDistinct: "array_distinct", ops.ArrayFlatten: "array_flatten", ops.ArrayIndex: "get", diff --git a/ibis/backends/sql/compilers/trino.py b/ibis/backends/sql/compilers/trino.py index 8cd27c623dab2..a821bc43535a6 100644 --- a/ibis/backends/sql/compilers/trino.py +++ b/ibis/backends/sql/compilers/trino.py @@ -60,6 +60,8 @@ class TrinoCompiler(SQLGlotCompiler): SIMPLE_OPS = { ops.Arbitrary: "any_value", + ops.ArgMax: "max_by", + ops.ArgMin: "min_by", ops.Pi: "pi", ops.E: "e", ops.RegexReplace: "regexp_replace",