Skip to content

Commit

Permalink
refactor(sqlglot): remove duplicated simple compilation rules and sort
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed Feb 12, 2024
1 parent cba2f98 commit d44001f
Showing 1 changed file with 51 additions and 54 deletions.
105 changes: 51 additions & 54 deletions ibis/backends/base/sqlglot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,79 +1187,76 @@ def visit_RegexExtract(self, op, *, arg, pattern, index):


_SIMPLE_OPS = {
ops.Abs: "abs",
ops.Acos: "acos",
ops.All: "bool_and",
ops.Any: "bool_or",
ops.ApproxCountDistinct: "approx_distinct",
ops.ArgMax: "max_by",
ops.ArgMin: "min_by",
ops.Power: "pow",
ops.IsNan: "isnan",
ops.IsInf: "isinf",
ops.Abs: "abs",
ops.Exp: "exp",
ops.Sqrt: "sqrt",
ops.Ln: "ln",
ops.Log2: "log2",
ops.Log10: "log",
ops.Acos: "acos",
ops.ArrayCollect: "array_agg",
ops.ArrayContains: "array_contains",
ops.ArrayFlatten: "flatten",
ops.ArrayLength: "array_size",
ops.ArraySort: "array_sort",
ops.ArrayStringJoin: "array_to_string",
ops.Asin: "asin",
ops.Atan: "atan",
ops.Atan2: "atan2",
ops.Atan: "atan",
ops.Capitalize: "initcap",
ops.Cos: "cos",
ops.Sin: "sin",
ops.Tan: "tan",
ops.Cot: "cot",
ops.Pi: "pi",
ops.RandomScalar: "random",
ops.Sign: "sign",
ops.ApproxCountDistinct: "approx_distinct",
ops.Median: "median",
ops.ArgMin: "argmin",
ops.ArgMax: "argmax",
ops.First: "first",
ops.Last: "last",
ops.Count: "count",
ops.ArrayCollect: "array_agg",
ops.CumeDist: "cume_dist",
ops.Date: "date",
ops.DateFromYMD: "datefromparts",
ops.Degrees: "degrees",
ops.DenseRank: "dense_rank",
ops.Exp: "exp",
ops.First: "first",
ops.FirstValue: "first_value",
ops.GroupConcat: "group_concat",
ops.StringContains: "contains",
ops.StringLength: "length",
ops.Lowercase: "lower",
ops.Uppercase: "upper",
ops.StartsWith: "starts_with",
ops.StrRight: "right",
ops.IfElse: "if",
ops.ArrayLength: "length",
ops.NullIf: "nullif",
ops.Repeat: "repeat",
ops.Map: "map",
ops.IsInf: "isinf",
ops.IsNan: "isnan",
ops.JSONGetItem: "json_extract",
ops.ArrayFlatten: "flatten",
ops.NTile: "ntile",
ops.Degrees: "degrees",
ops.Radians: "radians",
ops.FirstValue: "first_value",
ops.Last: "last",
ops.LastValue: "last_value",
ops.NthValue: "nth_value",
ops.Levenshtein: "levenshtein",
ops.Ln: "ln",
ops.Log10: "log",
ops.Log2: "log2",
ops.Lowercase: "lower",
ops.Map: "map",
ops.Median: "median",
ops.MinRank: "rank",
ops.DenseRank: "dense_rank",
ops.NTile: "ntile",
ops.NthValue: "nth_value",
ops.NullIf: "nullif",
ops.PercentRank: "percent_rank",
ops.CumeDist: "cume_dist",
ops.ArrayLength: "array_size",
ops.ArraySort: "array_sort",
ops.Capitalize: "initcap",
ops.Translate: "translate",
ops.StringReplace: "replace",
ops.Reverse: "reverse",
ops.StringSplit: "split",
ops.Pi: "pi",
ops.Power: "pow",
ops.Radians: "radians",
ops.RandomScalar: "random",
ops.RegexSearch: "regexp_like",
ops.DateFromYMD: "datefromparts",
ops.Date: "date",
ops.RegexSplit: "regexp_split",
ops.Repeat: "repeat",
ops.Reverse: "reverse",
ops.RowNumber: "row_number",
ops.Sign: "sign",
ops.Sin: "sin",
ops.Sqrt: "sqrt",
ops.StartsWith: "starts_with",
ops.StrRight: "right",
ops.StringContains: "contains",
ops.StringLength: "length",
ops.StringReplace: "replace",
ops.StringSplit: "split",
ops.StringToTimestamp: "str_to_time",
ops.ArrayStringJoin: "array_to_string",
ops.Levenshtein: "levenshtein",
ops.Tan: "tan",
ops.Translate: "translate",
ops.Unnest: "explode",
ops.RegexSplit: "regexp_split",
ops.ArrayContains: "array_contains",
ops.Uppercase: "upper",
}

_BINARY_INFIX_OPS = {
Expand Down

0 comments on commit d44001f

Please sign in to comment.