Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6241] Enable a few existing functions to hive library #3948

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

/** THE "DATE_ADD(date, interval)" function
* (BigQuery) adds the interval to the date. */
@LibraryOperator(libraries = {BIG_QUERY})
@LibraryOperator(libraries = {BIG_QUERY, HIVE})
public static final SqlFunction DATE_ADD =
SqlBasicFunction.create(SqlKind.DATE_ADD, ReturnTypes.ARG0_NULLABLE,
OperandTypes.DATE_INTERVAL)
Expand All @@ -132,9 +132,10 @@
public static final SqlFunction DATEADD =
new SqlTimestampAddFunction("DATEADD");

@LibraryOperator(libraries = {ORACLE, SPARK, HIVE})
/** The "DATE_ADD(date, numDays)" function
* (Spark) Returns the date that is num_days after start_date. */
@LibraryOperator(libraries = {SPARK})

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 17)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 8, oldest Guava, America/New_York Timezone)

[Task :core:compileJava] org.apache.calcite.sql.fun.LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / ErrorProne (JDK 11, latest Guava)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 8, latest Guava, America/New_York Timezone)

[Task :core:compileJava] org.apache.calcite.sql.fun.LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 11, Pacific/Chatham Timezone)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 23)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation interface @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 21)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation interface @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / CheckerFramework (JDK 11)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / CheckerFramework (JDK 11, oldest Guava)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / Druid Tests

[Task :core:compileJava] LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / Linux (JDK 11, Avatica main)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation type @LibraryOperator(libraries = {SPARK}) ^

Check failure on line 138 in core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java

View workflow job for this annotation

GitHub Actions / macOS (JDK 21)

[Task :core:compileJava] LibraryOperator is not a repeatable annotation interface @LibraryOperator(libraries = {SPARK}) ^
public static final SqlFunction DATE_ADD_SPARK =
SqlBasicFunction.create(SqlKind.DATE_ADD, ReturnTypes.DATE_NULLABLE,
OperandTypes.DATE_ANY)
Expand Down Expand Up @@ -162,7 +163,7 @@
* <p>MySQL has "DATEDIFF(date, date2)" and "TIMEDIFF(time, time2)" functions
* but Calcite does not implement these because they have no "timeUnit"
* argument. */
@LibraryOperator(libraries = {MSSQL, POSTGRESQL})
@LibraryOperator(libraries = {MSSQL, POSTGRESQL, HIVE})
public static final SqlFunction DATEDIFF =
new SqlTimestampDiffFunction("DATEDIFF",
OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.DATE,
Expand Down Expand Up @@ -225,7 +226,7 @@

/** The "DATE_SUB(date, interval)" function (BigQuery);
* subtracts interval from the date, independent of any time zone. */
@LibraryOperator(libraries = {BIG_QUERY})
@LibraryOperator(libraries = {BIG_QUERY, HIVE})
public static final SqlFunction DATE_SUB =
SqlBasicFunction.create(SqlKind.DATE_SUB, ReturnTypes.ARG0_NULLABLE,
OperandTypes.DATE_INTERVAL)
Expand Down Expand Up @@ -261,7 +262,7 @@
};

/** The "DECODE(v, v1, result1, [v2, result2, ...], resultN)" function. */
@LibraryOperator(libraries = {ORACLE, REDSHIFT, SPARK})
@LibraryOperator(libraries = {ORACLE, REDSHIFT, SPARK, HIVE})
public static final SqlFunction DECODE =
SqlBasicFunction.create(SqlKind.DECODE, DECODE_RETURN_TYPE,
OperandTypes.VARIADIC);
Expand Down Expand Up @@ -292,7 +293,7 @@
}

/** The "NVL(value, value)" function. */
@LibraryOperator(libraries = {ORACLE, REDSHIFT, SPARK})
@LibraryOperator(libraries = {ORACLE, REDSHIFT, SPARK, HIVE})
public static final SqlBasicFunction NVL =
SqlBasicFunction.create(SqlKind.NVL,
ReturnTypes.LEAST_RESTRICTIVE
Expand Down Expand Up @@ -337,7 +338,7 @@
SqlFunctionCategory.STRING);

/** The "RPAD(original_value, return_length[, pattern])" function. */
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, POSTGRESQL, SPARK})
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, POSTGRESQL, SPARK, HIVE})
public static final SqlFunction RPAD =
SqlBasicFunction.create(
"RPAD",
Expand All @@ -346,7 +347,7 @@
SqlFunctionCategory.STRING);

/** The "LTRIM(string)" function. */
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, POSTGRESQL, SPARK})
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, POSTGRESQL, SPARK, HIVE})
public static final SqlFunction LTRIM =
SqlBasicFunction.create(SqlKind.LTRIM,
ReturnTypes.ARG0.andThen(SqlTypeTransforms.TO_NULLABLE)
Expand All @@ -355,7 +356,7 @@
.withFunctionType(SqlFunctionCategory.STRING);

/** The "RTRIM(string)" function. */
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, POSTGRESQL, SPARK})
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, POSTGRESQL, SPARK, HIVE})
public static final SqlFunction RTRIM =
SqlBasicFunction.create(SqlKind.RTRIM,
ReturnTypes.ARG0.andThen(SqlTypeTransforms.TO_NULLABLE)
Expand Down Expand Up @@ -394,7 +395,7 @@
public static final SqlFunction STRPOS = new SqlPositionFunction("STRPOS");

/** The "INSTR(string, substring [, position [, occurrence]])" function. */
@LibraryOperator(libraries = {BIG_QUERY, MYSQL, ORACLE})
@LibraryOperator(libraries = {BIG_QUERY, MYSQL, ORACLE, HIVE})
public static final SqlFunction INSTR = new SqlPositionFunction("INSTR");

/** Generic "SUBSTR(string, position [, substringLength ])" function. */
Expand Down Expand Up @@ -473,7 +474,7 @@
SqlFunctionCategory.STRING);

/** The "GREATEST(value, value)" function. */
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, SPARK})
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, SPARK, HIVE})
public static final SqlFunction GREATEST =
SqlBasicFunction.create(SqlKind.GREATEST,
ReturnTypes.LEAST_RESTRICTIVE.andThen(SqlTypeTransforms.TO_NULLABLE),
Expand All @@ -487,7 +488,7 @@
OperandTypes.SAME_VARIADIC);

/** The "LEAST(value, value)" function. */
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, SPARK})
@LibraryOperator(libraries = {BIG_QUERY, ORACLE, SPARK, HIVE})
public static final SqlFunction LEAST =
SqlBasicFunction.create(SqlKind.LEAST,
ReturnTypes.LEAST_RESTRICTIVE.andThen(SqlTypeTransforms.TO_NULLABLE),
Expand Down Expand Up @@ -600,7 +601,7 @@
/** The "REGEXP_REPLACE(value, regexp, rep)"
* function. Replaces all substrings of value that match regexp with
* {@code rep} and returns modified value. */
@LibraryOperator(libraries = {MYSQL, ORACLE, REDSHIFT})
@LibraryOperator(libraries = {MYSQL, ORACLE, REDSHIFT, HIVE})
public static final SqlFunction REGEXP_REPLACE_3 =
SqlBasicFunction.create("REGEXP_REPLACE", ReturnTypes.VARCHAR_NULLABLE,
OperandTypes.STRING_STRING_STRING, SqlFunctionCategory.STRING);
Expand Down Expand Up @@ -1062,7 +1063,7 @@
ReturnTypes.ARG0_NULLABLE_VARYING,
OperandTypes.CBSTRING_INTEGER, SqlFunctionCategory.STRING);

@LibraryOperator(libraries = {BIG_QUERY, MYSQL, POSTGRESQL, SPARK})
@LibraryOperator(libraries = {BIG_QUERY, MYSQL, POSTGRESQL, SPARK, HIVE})
public static final SqlFunction REPEAT =
SqlBasicFunction.create("REPEAT",
ReturnTypes.VARCHAR_NULLABLE,
Expand All @@ -1074,7 +1075,7 @@
SqlBasicFunction.create("RIGHT", ReturnTypes.ARG0_NULLABLE_VARYING,
OperandTypes.CBSTRING_INTEGER, SqlFunctionCategory.STRING);

@LibraryOperator(libraries = {MYSQL, SPARK})
@LibraryOperator(libraries = {MYSQL, SPARK, HIVE})
public static final SqlFunction SPACE =
SqlBasicFunction.create("SPACE",
ReturnTypes.VARCHAR_NULLABLE,
Expand All @@ -1088,7 +1089,7 @@
OperandTypes.STRING_STRING,
SqlFunctionCategory.STRING);

@LibraryOperator(libraries = {BIG_QUERY, MYSQL, POSTGRESQL, ORACLE})
@LibraryOperator(libraries = {BIG_QUERY, MYSQL, POSTGRESQL, ORACLE, HIVE})
public static final SqlFunction SOUNDEX =
SqlBasicFunction.create("SOUNDEX",
ReturnTypes.VARCHAR_4_NULLABLE,
Expand Down Expand Up @@ -1884,7 +1885,7 @@

/** The "TO_DATE(string1, string2)" function; casts string1
* to a DATE using the format specified in string2. */
@LibraryOperator(libraries = {ORACLE, REDSHIFT})
@LibraryOperator(libraries = {ORACLE, REDSHIFT, HIVE})
public static final SqlFunction TO_DATE =
SqlBasicFunction.create("TO_DATE",
ReturnTypes.DATE_NULLABLE,
Expand Down Expand Up @@ -2449,7 +2450,7 @@
OperandTypes.STRING.or(OperandTypes.BINARY),
SqlFunctionCategory.STRING);

@LibraryOperator(libraries = {BIG_QUERY, MYSQL, POSTGRESQL, SPARK})
@LibraryOperator(libraries = {BIG_QUERY, MYSQL, POSTGRESQL, SPARK, HIVE})
public static final SqlFunction SHA1 =
SqlBasicFunction.create("SHA1",
ReturnTypes.VARCHAR_NULLABLE,
Expand Down Expand Up @@ -2500,7 +2501,7 @@

/** The "LOG(numeric1 [, numeric2 ]) " function. Returns the logarithm of numeric2
* to base numeric1.*/
@LibraryOperator(libraries = {MYSQL, SPARK})
@LibraryOperator(libraries = {MYSQL, SPARK, HIVE})
public static final SqlFunction LOG_MYSQL =
SqlBasicFunction.create(SqlKind.LOG,
ReturnTypes.DOUBLE_FORCE_NULLABLE,
Expand Down
Loading
Loading