Skip to content

Commit 45c15bb

Browse files
committed
Roll back the upgrade of Calcite
1 parent 2515bdb commit 45c15bb

File tree

5 files changed

+37
-71
lines changed

5 files changed

+37
-71
lines changed

flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/JaninoCompiler.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.calcite.sql.SqlCharStringLiteral;
2929
import org.apache.calcite.sql.SqlDataTypeSpec;
3030
import org.apache.calcite.sql.SqlIdentifier;
31-
import org.apache.calcite.sql.SqlIntervalQualifier;
3231
import org.apache.calcite.sql.SqlLiteral;
3332
import org.apache.calcite.sql.SqlNode;
3433
import org.apache.calcite.sql.SqlNodeList;
@@ -201,19 +200,6 @@ private static Java.Rvalue translateSqlCase(
201200
return new Java.ParenthesizedExpression(Location.NOWHERE, sqlCaseRvalueTemp);
202201
}
203202

204-
private static Java.Rvalue translateSqlSqlIntervalQualifier(
205-
SqlIntervalQualifier sqlIntervalQualifier) {
206-
if (sqlIntervalQualifier.timeFrameName != null) {
207-
return new Java.AmbiguousName(
208-
Location.NOWHERE, new String[] {sqlIntervalQualifier.timeFrameName});
209-
}
210-
if (sqlIntervalQualifier.timeUnitRange == null) {
211-
return new Java.NullLiteral(Location.NOWHERE);
212-
}
213-
String value = "\"" + sqlIntervalQualifier.timeUnitRange.name() + "\"";
214-
return new Java.AmbiguousName(Location.NOWHERE, new String[] {value});
215-
}
216-
217203
private static void translateSqlNodeToAtoms(
218204
SqlNode sqlNode,
219205
List<Java.Rvalue> atoms,
@@ -230,8 +216,6 @@ private static void translateSqlNodeToAtoms(
230216
}
231217
} else if (sqlNode instanceof SqlCase) {
232218
atoms.add(translateSqlCase((SqlCase) sqlNode, udfDescriptors));
233-
} else if (sqlNode instanceof SqlIntervalQualifier) {
234-
atoms.add(translateSqlSqlIntervalQualifier((SqlIntervalQualifier) sqlNode));
235219
}
236220
}
237221

@@ -290,8 +274,6 @@ private static Java.Rvalue sqlBasicCallToJaninoRvalue(
290274
return generateTimestampDiffOperation(sqlBasicCall, atoms);
291275
case TIMESTAMP_ADD:
292276
return generateTimestampAddOperation(sqlBasicCall, atoms);
293-
case CHAR_LENGTH:
294-
return generateCharLengthOperation(atoms);
295277
case OTHER:
296278
return generateOtherOperation(sqlBasicCall, atoms);
297279
default:

flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/typeutils/DataTypeConverter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public static RelDataType convertCalciteType(
133133
case TIMESTAMP_WITHOUT_TIME_ZONE:
134134
return typeFactory.createSqlType(SqlTypeName.TIMESTAMP);
135135
case TIMESTAMP_WITH_TIME_ZONE:
136-
return typeFactory.createSqlType(SqlTypeName.TIMESTAMP_TZ);
136+
throw new UnsupportedOperationException("Unsupported type: TIMESTAMP_TZ");
137137
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
138138
return typeFactory.createSqlType(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE);
139139
case FLOAT:
@@ -192,8 +192,6 @@ public static DataType convertCalciteRelDataTypeToDataType(RelDataType relDataTy
192192
return DataTypes.TIME(relDataType.getPrecision());
193193
case TIMESTAMP:
194194
return DataTypes.TIMESTAMP(relDataType.getPrecision());
195-
case TIMESTAMP_TZ:
196-
return DataTypes.TIMESTAMP_TZ(relDataType.getPrecision());
197195
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
198196
return DataTypes.TIMESTAMP_LTZ(relDataType.getPrecision());
199197
case FLOAT:

flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/operators/transform/PostTransformOperatorTest.java

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ public class PostTransformOperatorTest {
164164
.physicalColumn("interval_value", DataTypes.INT())
165165
.physicalColumn("time_point_timestamp", DataTypes.TIMESTAMP(0))
166166
.physicalColumn("time_point_timestamp_ltz", DataTypes.TIMESTAMP_LTZ(0))
167-
.physicalColumn("time_point_timestamp_tz", DataTypes.TIMESTAMP_TZ(0))
168167
.primaryKey("col1")
169168
.build();
170169

@@ -1454,43 +1453,37 @@ void testTimestampaddTransformData() throws Exception {
14541453
TIMESTAMPADD_DATA_TABLEID.identifier(),
14551454
"col1, time_interval_unit, interval_value,"
14561455
+ " TIMESTAMPADD(SECOND, interval_value, time_point_timestamp) as time_point_timestamp,"
1457-
+ " TIMESTAMPADD(SECOND, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz,"
1458-
+ " TIMESTAMPADD(SECOND, interval_value, time_point_timestamp_tz) as time_point_timestamp_tz",
1456+
+ " TIMESTAMPADD(SECOND, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz",
14591457
"time_interval_unit='SECOND'")
14601458
.addTransform(
14611459
TIMESTAMPADD_DATA_TABLEID.identifier(),
14621460
"col1, time_interval_unit, interval_value,"
14631461
+ " TIMESTAMPADD(MINUTE, interval_value, time_point_timestamp) as time_point_timestamp,"
1464-
+ " TIMESTAMPADD(MINUTE, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz,"
1465-
+ " TIMESTAMPADD(MINUTE, interval_value, time_point_timestamp_tz) as time_point_timestamp_tz",
1462+
+ " TIMESTAMPADD(MINUTE, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz",
14661463
"time_interval_unit='MINUTE'")
14671464
.addTransform(
14681465
TIMESTAMPADD_DATA_TABLEID.identifier(),
14691466
"col1, time_interval_unit, interval_value,"
14701467
+ " TIMESTAMPADD(HOUR, interval_value, time_point_timestamp) as time_point_timestamp,"
1471-
+ " TIMESTAMPADD(HOUR, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz,"
1472-
+ " TIMESTAMPADD(HOUR, interval_value, time_point_timestamp_tz) as time_point_timestamp_tz",
1468+
+ " TIMESTAMPADD(HOUR, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz",
14731469
"time_interval_unit='HOUR'")
14741470
.addTransform(
14751471
TIMESTAMPADD_DATA_TABLEID.identifier(),
14761472
"col1, time_interval_unit, interval_value,"
14771473
+ " TIMESTAMPADD(DAY, interval_value, time_point_timestamp) as time_point_timestamp,"
1478-
+ " TIMESTAMPADD(DAY, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz,"
1479-
+ " TIMESTAMPADD(DAY, interval_value, time_point_timestamp_tz) as time_point_timestamp_tz",
1474+
+ " TIMESTAMPADD(DAY, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz",
14801475
"time_interval_unit='DAY'")
14811476
.addTransform(
14821477
TIMESTAMPADD_DATA_TABLEID.identifier(),
14831478
"col1, time_interval_unit, interval_value,"
14841479
+ " TIMESTAMPADD(MONTH, interval_value, time_point_timestamp) as time_point_timestamp,"
1485-
+ " TIMESTAMPADD(MONTH, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz,"
1486-
+ " TIMESTAMPADD(MONTH, interval_value, time_point_timestamp_tz) as time_point_timestamp_tz",
1480+
+ " TIMESTAMPADD(MONTH, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz",
14871481
"time_interval_unit='MONTH'")
14881482
.addTransform(
14891483
TIMESTAMPADD_DATA_TABLEID.identifier(),
14901484
"col1, time_interval_unit, interval_value,"
14911485
+ " TIMESTAMPADD(YEAR, interval_value, time_point_timestamp) as time_point_timestamp,"
1492-
+ " TIMESTAMPADD(YEAR, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz,"
1493-
+ " TIMESTAMPADD(YEAR, interval_value, time_point_timestamp_tz) as time_point_timestamp_tz",
1486+
+ " TIMESTAMPADD(YEAR, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz",
14941487
"time_interval_unit='YEAR'")
14951488
.addTimezone("UTC")
14961489
.build();
@@ -1523,7 +1516,6 @@ void testTimestampaddTransformData() throws Exception {
15231516
1735689600,
15241517
TimestampData.fromMillis(0, 0),
15251518
LocalZonedTimestampData.fromEpochMillis(0, 0),
1526-
ZonedTimestampData.of(0, 0, "UTC"),
15271519
}));
15281520
DataChangeEvent insertEventExpect1 =
15291521
DataChangeEvent.insertEvent(
@@ -1535,7 +1527,6 @@ void testTimestampaddTransformData() throws Exception {
15351527
1735689600,
15361528
TimestampData.fromMillis(1735689600000L, 0),
15371529
LocalZonedTimestampData.fromEpochMillis(1735689600000L, 0),
1538-
ZonedTimestampData.of(1735689600000L, 0, "UTC"),
15391530
}));
15401531
transform.processElement(new StreamRecord<>(insertEvent1));
15411532
Assertions.assertThat(
@@ -1553,7 +1544,6 @@ void testTimestampaddTransformData() throws Exception {
15531544
28928160,
15541545
TimestampData.fromMillis(0, 0),
15551546
LocalZonedTimestampData.fromEpochMillis(0, 0),
1556-
ZonedTimestampData.of(0, 0, "UTC"),
15571547
}));
15581548
DataChangeEvent insertEventExpect2 =
15591549
DataChangeEvent.insertEvent(
@@ -1565,7 +1555,6 @@ void testTimestampaddTransformData() throws Exception {
15651555
28928160,
15661556
TimestampData.fromMillis(1735689600000L, 0),
15671557
LocalZonedTimestampData.fromEpochMillis(1735689600000L, 0),
1568-
ZonedTimestampData.of(1735689600000L, 0, "UTC"),
15691558
}));
15701559
transform.processElement(new StreamRecord<>(insertEvent2));
15711560
Assertions.assertThat(
@@ -1583,7 +1572,6 @@ void testTimestampaddTransformData() throws Exception {
15831572
482136,
15841573
TimestampData.fromMillis(0, 0),
15851574
LocalZonedTimestampData.fromEpochMillis(0, 0),
1586-
ZonedTimestampData.of(0, 0, "UTC"),
15871575
}));
15881576
DataChangeEvent insertEventExpect3 =
15891577
DataChangeEvent.insertEvent(
@@ -1595,7 +1583,6 @@ void testTimestampaddTransformData() throws Exception {
15951583
482136,
15961584
TimestampData.fromMillis(1735689600000L, 0),
15971585
LocalZonedTimestampData.fromEpochMillis(1735689600000L, 0),
1598-
ZonedTimestampData.of(1735689600000L, 0, "UTC"),
15991586
}));
16001587
transform.processElement(new StreamRecord<>(insertEvent3));
16011588
Assertions.assertThat(
@@ -1613,7 +1600,6 @@ void testTimestampaddTransformData() throws Exception {
16131600
20089,
16141601
TimestampData.fromMillis(0, 0),
16151602
LocalZonedTimestampData.fromEpochMillis(0, 0),
1616-
ZonedTimestampData.of(0, 0, "UTC"),
16171603
}));
16181604
DataChangeEvent insertEventExpect4 =
16191605
DataChangeEvent.insertEvent(
@@ -1625,7 +1611,6 @@ void testTimestampaddTransformData() throws Exception {
16251611
20089,
16261612
TimestampData.fromMillis(1735689600000L, 0),
16271613
LocalZonedTimestampData.fromEpochMillis(1735689600000L, 0),
1628-
ZonedTimestampData.of(1735689600000L, 0, "UTC"),
16291614
}));
16301615
transform.processElement(new StreamRecord<>(insertEvent4));
16311616
Assertions.assertThat(
@@ -1643,7 +1628,6 @@ void testTimestampaddTransformData() throws Exception {
16431628
660,
16441629
TimestampData.fromMillis(0, 0),
16451630
LocalZonedTimestampData.fromEpochMillis(0, 0),
1646-
ZonedTimestampData.of(0, 0, "UTC"),
16471631
}));
16481632
DataChangeEvent insertEventExpect5 =
16491633
DataChangeEvent.insertEvent(
@@ -1655,7 +1639,6 @@ void testTimestampaddTransformData() throws Exception {
16551639
660,
16561640
TimestampData.fromMillis(1735689600000L, 0),
16571641
LocalZonedTimestampData.fromEpochMillis(1735689600000L, 0),
1658-
ZonedTimestampData.of(1735689600000L, 0, "UTC"),
16591642
}));
16601643
transform.processElement(new StreamRecord<>(insertEvent5));
16611644
Assertions.assertThat(
@@ -1673,7 +1656,6 @@ void testTimestampaddTransformData() throws Exception {
16731656
55,
16741657
TimestampData.fromMillis(0, 0),
16751658
LocalZonedTimestampData.fromEpochMillis(0, 0),
1676-
ZonedTimestampData.of(0, 0, "UTC"),
16771659
}));
16781660
DataChangeEvent insertEventExpect6 =
16791661
DataChangeEvent.insertEvent(
@@ -1685,7 +1667,6 @@ void testTimestampaddTransformData() throws Exception {
16851667
55,
16861668
TimestampData.fromMillis(1735689600000L, 0),
16871669
LocalZonedTimestampData.fromEpochMillis(1735689600000L, 0),
1688-
ZonedTimestampData.of(1735689600000L, 0, "UTC"),
16891670
}));
16901671
transform.processElement(new StreamRecord<>(insertEvent6));
16911672
Assertions.assertThat(
@@ -1703,7 +1684,6 @@ void testTimestampaddTransformData() throws Exception {
17031684
null,
17041685
TimestampData.fromMillis(0, 0),
17051686
LocalZonedTimestampData.fromEpochMillis(0, 0),
1706-
ZonedTimestampData.of(0, 0, "UTC"),
17071687
}));
17081688
DataChangeEvent insertEventExpect7 =
17091689
DataChangeEvent.insertEvent(
@@ -1715,7 +1695,6 @@ void testTimestampaddTransformData() throws Exception {
17151695
null,
17161696
null,
17171697
null,
1718-
null,
17191698
}));
17201699
transform.processElement(new StreamRecord<>(insertEvent7));
17211700
Assertions.assertThat(

flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/parser/TransformParserTest.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -254,25 +254,25 @@ public void testTranslateFilterToJaninoExpression() {
254254
testFilterExpression(
255255
"TIMESTAMP_DIFF('SECOND', dt1, dt2)", "timestampDiff(\"SECOND\", dt1, dt2)");
256256
testFilterExpression(
257-
"timestamp_diff('second', dt1, dt2)", "timestampDiff(\"SECOND\", dt1, dt2)");
257+
"timestamp_diff('second', dt1, dt2)", "timestampDiff(\"second\", dt1, dt2)");
258258
testFilterExpression(
259259
"TIMESTAMP_DIFF('MINUTE', dt1, dt2)", "timestampDiff(\"MINUTE\", dt1, dt2)");
260260
testFilterExpression(
261-
"timestamp_diff('minute', dt1, dt2)", "timestampDiff(\"MINUTE\", dt1, dt2)");
261+
"timestamp_diff('minute', dt1, dt2)", "timestampDiff(\"minute\", dt1, dt2)");
262262
testFilterExpression(
263263
"TIMESTAMP_DIFF('HOUR', dt1, dt2)", "timestampDiff(\"HOUR\", dt1, dt2)");
264264
testFilterExpression(
265-
"timestamp_diff('hour', dt1, dt2)", "timestampDiff(\"HOUR\", dt1, dt2)");
265+
"timestamp_diff('hour', dt1, dt2)", "timestampDiff(\"hour\", dt1, dt2)");
266266
testFilterExpression("TIMESTAMP_DIFF('DAY', dt1, dt2)", "timestampDiff(\"DAY\", dt1, dt2)");
267-
testFilterExpression("timestamp_diff('day', dt1, dt2)", "timestampDiff(\"DAY\", dt1, dt2)");
267+
testFilterExpression("timestamp_diff('day', dt1, dt2)", "timestampDiff(\"day\", dt1, dt2)");
268268
testFilterExpression(
269269
"TIMESTAMP_DIFF('MONTH', dt1, dt2)", "timestampDiff(\"MONTH\", dt1, dt2)");
270270
testFilterExpression(
271-
"timestamp_diff('month', dt1, dt2)", "timestampDiff(\"MONTH\", dt1, dt2)");
271+
"timestamp_diff('month', dt1, dt2)", "timestampDiff(\"month\", dt1, dt2)");
272272
testFilterExpression(
273273
"TIMESTAMP_DIFF('YEAR', dt1, dt2)", "timestampDiff(\"YEAR\", dt1, dt2)");
274274
testFilterExpression(
275-
"timestamp_diff('year', dt1, dt2)", "timestampDiff(\"YEAR\", dt1, dt2)");
275+
"timestamp_diff('year', dt1, dt2)", "timestampDiff(\"year\", dt1, dt2)");
276276
testFilterExpression(
277277
"TIMESTAMPDIFF(SECOND, dt1, dt2)", "timestampdiff(\"SECOND\", dt1, dt2)");
278278
testFilterExpression(
@@ -364,27 +364,13 @@ public void testTranslateFilterToJaninoExpression() {
364364

365365
@Test
366366
public void testTranslateFilterToJaninoExpressionError() {
367-
Assertions.assertThatThrownBy(
368-
() -> {
369-
TransformParser.translateFilterExpressionToJaninoExpression(
370-
"TIMESTAMP_DIFF(SECONDS, dt1, dt2)", Collections.emptyList());
371-
})
372-
.isExactlyInstanceOf(ParseException.class)
373-
.hasMessage("Unsupported time interval unit in timestamp diff function: SECONDS");
374-
Assertions.assertThatThrownBy(
375-
() -> {
376-
TransformParser.translateFilterExpressionToJaninoExpression(
377-
"TIMESTAMP_DIFF(QUARTER, dt1, dt2)", Collections.emptyList());
378-
})
379-
.isExactlyInstanceOf(ParseException.class)
380-
.hasMessage("Unsupported time interval unit in timestamp diff function: QUARTER");
381367
Assertions.assertThatThrownBy(
382368
() -> {
383369
TransformParser.translateFilterExpressionToJaninoExpression(
384370
"TIMESTAMPDIFF(SECONDS, dt1, dt2)", Collections.emptyList());
385371
})
386372
.isExactlyInstanceOf(ParseException.class)
387-
.hasMessage("Unsupported time interval unit in timestamp diff function: SECONDS");
373+
.hasMessage("Statements can not be parsed.");
388374
Assertions.assertThatThrownBy(
389375
() -> {
390376
TransformParser.translateFilterExpressionToJaninoExpression(
@@ -399,7 +385,7 @@ public void testTranslateFilterToJaninoExpressionError() {
399385
"TIMESTAMPADD(SECONDS, dt1, dt2)", Collections.emptyList());
400386
})
401387
.isExactlyInstanceOf(ParseException.class)
402-
.hasMessage("Unsupported time interval unit in timestamp add function: SECONDS");
388+
.hasMessage("Statements can not be parsed.");
403389
Assertions.assertThatThrownBy(
404390
() -> {
405391
TransformParser.translateFilterExpressionToJaninoExpression(

0 commit comments

Comments
 (0)