-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[CALCITE-7428] Support regexp function change regexp operator for Hive library #4818
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -705,11 +705,10 @@ static RelDataType deriveTypeSplit(SqlOperatorBinding operatorBinding, | |
| public static final SqlFunction REGEXP_SUBSTR = REGEXP_EXTRACT.withName("REGEXP_SUBSTR"); | ||
|
|
||
| /** The "REGEXP(value, regexp)" function, equivalent to {@link #RLIKE}. */ | ||
| @LibraryOperator(libraries = {SPARK}) | ||
| @LibraryOperator(libraries = {SPARK, HIVE}) | ||
| public static final SqlFunction REGEXP = | ||
| SqlBasicFunction.create("REGEXP", ReturnTypes.BOOLEAN_NULLABLE, | ||
| OperandTypes.STRING_STRING, | ||
| SqlFunctionCategory.STRING); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove this line?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed this part, ignore it. |
||
| SqlBasicFunction.create("REGEXP", SqlKind.RLIKE, ReturnTypes.BOOLEAN_NULLABLE, | ||
| OperandTypes.STRING_STRING); | ||
|
|
||
| /** The "REGEXP_LIKE(value, regexp)" function, equivalent to {@link #RLIKE}. */ | ||
| @LibraryOperator(libraries = {SPARK, MYSQL, POSTGRESQL, ORACLE}) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11761,4 +11761,36 @@ public Sql schema(CalciteAssert.SchemaSpec schemaSpec) { | |
| .ok(expected); | ||
| } | ||
|
|
||
| /** Test case for | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are there tests for REGEXP without HIVE? |
||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-7428">[CALCITE-7428] | ||
| * Support regexp function change regexp operator for Hive library</a>. */ | ||
| @Test void testRegexpWithHive() { | ||
| final String query = "select \"brand_name\"\n" | ||
| + "from \"product\" where REGEXP(\"brand_name\",'[a-zA-Z]') "; | ||
| final String expectedHive = "SELECT `brand_name`\nFROM " | ||
| + "`foodmart`.`product`\nWHERE (`brand_name` REGEXP '[a-zA-Z]')"; | ||
| sql(query).withLibrary(SqlLibrary.HIVE).withHive().ok(expectedHive); | ||
| } | ||
|
|
||
| /** Test case for | ||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-7428">[CALCITE-7428] | ||
| * Support regexp function change regexp operator for Hive library</a>. */ | ||
| @Test void testRegexpWithHiveIsNotNull() { | ||
| final String query = "select \"brand_name\"\n" | ||
| + "from \"product\" where REGEXP(\"brand_name\",'[a-zA-Z]') is not null "; | ||
| final String expectedHive = "SELECT `brand_name`\nFROM " | ||
| + "`foodmart`.`product`\nWHERE (`brand_name` REGEXP '[a-zA-Z]') IS NOT NULL"; | ||
| sql(query).withLibrary(SqlLibrary.HIVE).withHive().ok(expectedHive); | ||
| } | ||
|
|
||
| /** Test case for | ||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-7428">[CALCITE-7428] | ||
| * Support regexp function change regexp operator for Hive library</a>. */ | ||
| @Test void testSelectRegexpWithHiveIsNotNull() { | ||
| final String query = "select REGEXP(\"brand_name\",'[a-zA-Z]') is not null \n" | ||
| + "from \"product\""; | ||
| final String expectedHive = "SELECT (`brand_name` REGEXP '[a-zA-Z]') IS NOT NULL\n" | ||
| + "FROM `foodmart`.`product`"; | ||
| sql(query).withLibrary(SqlLibrary.HIVE).withHive().ok(expectedHive); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's been added to libraries in this PR, Hive should also be added to SqlOperatorTest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done