raminqaf commented on code in PR #28140:
URL: https://github.com/apache/flink/pull/28140#discussion_r3219141411
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/RegexpFunctionsITCase.java:
##########
@@ -121,17 +121,51 @@ private Stream<TestSetSpec> regexpExtractTestCases() {
return Stream.of(
TestSetSpec.forFunction(
BuiltInFunctionDefinitions.REGEXP_EXTRACT,
"Check return type")
- .onFieldsWithData("22", "ABC")
+ .onFieldsWithData("22", "ABC", "(")
.testResult(
- call("regexpExtract", $("f0"), "[A-Z]+"),
- "REGEXP_EXTRACT(f0,'[A-Z]+')",
+ $("f0").regexpExtract("[A-Z]+"),
+ "REGEXP_EXTRACT(f0, '[A-Z]+')",
null,
DataTypes.STRING().nullable())
.testResult(
- call("regexpExtract", $("f1"), "[A-Z]+"),
+ $("f1").regexpExtract("[A-Z]+"),
"REGEXP_EXTRACT(f1, '[A-Z]+')",
"ABC",
- DataTypes.STRING().nullable()));
+ DataTypes.STRING().nullable())
+ // Non-literal invalid regex (column ref): plan-time
validation does
+ // not apply, and the runtime swallows
PatternSyntaxException and
+ // returns null.
+ .testResult(
+ $("f1").regexpExtract($("f2")),
+ "REGEXP_EXTRACT(f1, f2)",
+ null,
+ DataTypes.STRING().nullable())
+ // Function-call regex. Calcite's
ReduceExpressionsRule folds it after
+ // type inference runs, so it is treated as
non-literal by the strategy
+ // and reaches the runtime path. Valid folded result:
extraction works.
+ .testResult(
+ $("f1").regexpExtract(concat("[A-", "Z]+")),
+ "REGEXP_EXTRACT(f1, '[A-' || 'Z]+')",
+ "ABC",
+ DataTypes.STRING().nullable())
+ // Function-call regex that folds to an invalid
pattern. Runtime
+ // returns null silently, no PatternSyntaxException
propagates.
Review Comment:
Removed comments in the ITs
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/RegexpFunctionsITCase.java:
##########
@@ -121,17 +121,51 @@ private Stream<TestSetSpec> regexpExtractTestCases() {
return Stream.of(
TestSetSpec.forFunction(
BuiltInFunctionDefinitions.REGEXP_EXTRACT,
"Check return type")
- .onFieldsWithData("22", "ABC")
+ .onFieldsWithData("22", "ABC", "(")
.testResult(
- call("regexpExtract", $("f0"), "[A-Z]+"),
- "REGEXP_EXTRACT(f0,'[A-Z]+')",
+ $("f0").regexpExtract("[A-Z]+"),
+ "REGEXP_EXTRACT(f0, '[A-Z]+')",
null,
DataTypes.STRING().nullable())
.testResult(
- call("regexpExtract", $("f1"), "[A-Z]+"),
+ $("f1").regexpExtract("[A-Z]+"),
"REGEXP_EXTRACT(f1, '[A-Z]+')",
"ABC",
- DataTypes.STRING().nullable()));
+ DataTypes.STRING().nullable())
+ // Non-literal invalid regex (column ref): plan-time
validation does
+ // not apply, and the runtime swallows
PatternSyntaxException and
+ // returns null.
+ .testResult(
+ $("f1").regexpExtract($("f2")),
+ "REGEXP_EXTRACT(f1, f2)",
+ null,
+ DataTypes.STRING().nullable())
+ // Function-call regex. Calcite's
ReduceExpressionsRule folds it after
+ // type inference runs, so it is treated as
non-literal by the strategy
Review Comment:
Removed comments in the ITs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]