@ -18,6 +18,7 @@
package org.apache.flink.cdc.runtime.operators.transform ;
import org.apache.flink.cdc.common.data.DecimalData ;
import org.apache.flink.cdc.common.data.LocalZonedTimestampData ;
import org.apache.flink.cdc.common.data.TimestampData ;
import org.apache.flink.cdc.common.data.binary.BinaryStringData ;
import org.apache.flink.cdc.common.event.CreateTableEvent ;
@ -158,6 +159,57 @@ public class PostTransformOperatorTest {
. physicalColumn ( "minute_diff" , DataTypes . INT ( ) )
. physicalColumn ( "hour_diff" , DataTypes . INT ( ) )
. physicalColumn ( "day_diff" , DataTypes . INT ( ) )
. physicalColumn ( "month_diff" , DataTypes . INT ( ) )
. physicalColumn ( "year_diff" , DataTypes . INT ( ) )
. primaryKey ( "col1" )
. build ( ) ;
private static final TableId TIMESTAMPDIFF_DATA_TABLEID =
TableId . tableId ( "my_company" , "my_branch" , "timestampdiff_data_table" ) ;
private static final Schema TIMESTAMPDIFF_DATA_SCHEMA =
Schema . newBuilder ( )
. physicalColumn ( "col1" , DataTypes . STRING ( ) )
. physicalColumn ( "time_interval_unit" , DataTypes . STRING ( ) )
. physicalColumn ( "start_timestamp" , DataTypes . TIMESTAMP ( ) )
. physicalColumn ( "end_timestamp" , DataTypes . TIMESTAMP ( ) )
. physicalColumn ( "start_timestamp_ltz" , DataTypes . TIMESTAMP_LTZ ( ) )
. physicalColumn ( "end_timestamp_ltz" , DataTypes . TIMESTAMP_LTZ ( ) )
. primaryKey ( "col1" )
. build ( ) ;
private static final Schema EXPECTED_TIMESTAMPDIFF_DATA_SCHEMA =
Schema . newBuilder ( )
. physicalColumn ( "col1" , DataTypes . STRING ( ) . notNull ( ) )
. physicalColumn ( "time_interval_unit" , DataTypes . STRING ( ) )
. physicalColumn ( "timestamp_timestamp" , DataTypes . INT ( ) )
. physicalColumn ( "timestamp_timestamp_ltz" , DataTypes . INT ( ) )
. physicalColumn ( "timestamp_ltz_timestamp" , DataTypes . INT ( ) )
. physicalColumn ( "timestamp_ltz_timestamp_ltz" , DataTypes . INT ( ) )
. primaryKey ( "col1" )
. build ( ) ;
private static final TableId TIMESTAMPADD_DATA_TABLEID =
TableId . tableId ( "my_company" , "my_branch" , "timestampadd_data_table" ) ;
private static final Schema TIMESTAMPADD_DATA_SCHEMA =
Schema . newBuilder ( )
. physicalColumn ( "col1" , DataTypes . STRING ( ) . notNull ( ) )
. physicalColumn ( "time_interval_unit" , DataTypes . STRING ( ) )
. physicalColumn ( "interval_value" , DataTypes . INT ( ) )
. physicalColumn ( "time_point_timestamp" , DataTypes . TIMESTAMP ( 0 ) )
. physicalColumn ( "time_point_timestamp_ltz" , DataTypes . TIMESTAMP_LTZ ( 0 ) )
. primaryKey ( "col1" )
. build ( ) ;
private static final TableId TIMESTAMPADD_TABLEID =
TableId . tableId ( "my_company" , "my_branch" , "timestampadd_table" ) ;
private static final Schema TIMESTAMPADD_SCHEMA =
Schema . newBuilder ( )
. physicalColumn ( "col1" , DataTypes . STRING ( ) . notNull ( ) )
. physicalColumn ( "second_add" , DataTypes . STRING ( ) )
. physicalColumn ( "minute_add" , DataTypes . STRING ( ) )
. physicalColumn ( "hour_add" , DataTypes . STRING ( ) )
. physicalColumn ( "day_add" , DataTypes . STRING ( ) )
. physicalColumn ( "month_add" , DataTypes . STRING ( ) )
. physicalColumn ( "year_add" , DataTypes . STRING ( ) )
. primaryKey ( "col1" )
. build ( ) ;
@ -205,7 +257,7 @@ public class PostTransformOperatorTest {
private static final Schema TIMEZONE_SCHEMA =
Schema . newBuilder ( )
. physicalColumn ( "col1" , DataTypes . STRING ( ) . notNull ( ) )
. physicalColumn ( "datetime ", DataTypes . STRING ( ) )
. physicalColumn ( "datetime _value ", DataTypes . STRING ( ) )
. primaryKey ( "col1" )
. build ( ) ;
@ -1184,22 +1236,26 @@ public class PostTransformOperatorTest {
}
@Test
void testTimestamp D iffTransform( ) throws Exception {
void testTimestamp d iffTransform( ) throws Exception {
PostTransformOperator transform =
PostTransformOperator . newBuilder ( )
. addTransform (
TIMESTAMPDIFF_TABLEID . identifier ( ) ,
"col1, TIMESTAMP_DIFF('SECOND', LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as second_diff,"
+ " TIMESTAMP_DIFF('MINUTE', LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as minute_diff,"
+ " TIMESTAMP_DIFF('HOUR', LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as hour_diff,"
+ " TIMESTAMP_DIFF('DAY', LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as day_diff" ,
"col1, TIMESTAMPDIFF(SECOND, LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as second_diff,"
+ " TIMESTAMPDIFF(MINUTE, LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as minute_diff,"
+ " TIMESTAMPDIFF(HOUR, LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as hour_diff,"
+ " TIMESTAMPDIFF(DAY, LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as day_diff,"
+ " TIMESTAMPDIFF(MONTH, LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as month_diff,"
+ " TIMESTAMPDIFF(YEAR, LOCALTIMESTAMP, CAST(CURRENT_TIMESTAMP AS TIMESTAMP)) as year_diff" ,
"col1='1'" )
. addTransform (
TIMESTAMPDIFF_TABLEID . identifier ( ) ,
"col1, TIMESTAMP_DIFF('SECOND', LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as second_diff,"
+ " TIMESTAMP_DIFF('MINUTE', LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as minute_diff,"
+ " TIMESTAMP_DIFF('HOUR', LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as hour_diff,"
+ " TIMESTAMP_DIFF('DAY', LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as day_diff" ,
"col1, TIMESTAMPDIFF(SECOND, LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as second_diff,"
+ " TIMESTAMPDIFF(MINUTE, LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as minute_diff,"
+ " TIMESTAMPDIFF(HOUR, LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as hour_diff,"
+ " TIMESTAMPDIFF(DAY, LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as day_diff,"
+ " TIMESTAMPDIFF(MONTH, LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as month_diff,"
+ " TIMESTAMPDIFF(YEAR, LOCALTIMESTAMP, CAST(NOW() AS TIMESTAMP)) as year_diff" ,
"col1='2'" )
. addTimezone ( "Asia/Shanghai" )
. build ( ) ;
@ -1218,12 +1274,14 @@ public class PostTransformOperatorTest {
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_TABLEID ,
recordDataGenerator . generate (
new Object [ ] { new BinaryStringData ( "1" ) , null , null , null , null } ) ) ;
new Object [ ] {
new BinaryStringData ( "1" ) , null , null , null , null , null , null
} ) ) ;
DataChangeEvent insertEventExpect =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_TABLEID ,
recordDataGenerator . generate (
new Object [ ] { new BinaryStringData ( "1" ) , 0 , 0 , 0 , 0 }) ) ;
new Object [ ] { new BinaryStringData ( "1" ) , 0 , 0 , 0 , 0 , 0 , 0 }) ) ;
transform . processElement ( new StreamRecord < > ( createTableEvent ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
@ -1239,12 +1297,448 @@ public class PostTransformOperatorTest {
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_TABLEID ,
recordDataGenerator . generate (
new Object [ ] { new BinaryStringData ( "2" ) , null , null , null , null } ) ) ;
new Object [ ] {
new BinaryStringData ( "2" ) , null , null , null , null , null , null
} ) ) ;
DataChangeEvent insertEventExpect2 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_TABLEID ,
recordDataGenerator . generate (
new Object [ ] { new BinaryStringData ( "2" ) , 0 , 0 , 0 , 0 } ) ) ;
new Object [ ] { new BinaryStringData ( "2" ) , 0 , 0 , 0 , 0 , 0 , 0 } ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent2 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect2 ) ) ;
}
@Test
void testTimestampdiffTransformData ( ) throws Exception {
PostTransformOperator transform =
PostTransformOperator . newBuilder ( )
. addTransform (
TIMESTAMPDIFF_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit,"
+ " TIMESTAMPDIFF(SECOND, start_timestamp, end_timestamp) as timestamp_timestamp,"
+ " TIMESTAMPDIFF(SECOND, start_timestamp, end_timestamp_ltz) as timestamp_timestamp_ltz,"
+ " TIMESTAMPDIFF(SECOND, start_timestamp_ltz, end_timestamp) as timestamp_ltz_timestamp,"
+ " TIMESTAMPDIFF(SECOND, start_timestamp_ltz, end_timestamp_ltz) as timestamp_ltz_timestamp_ltz" ,
"time_interval_unit='SECOND'" )
. addTransform (
TIMESTAMPDIFF_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit,"
+ " TIMESTAMPDIFF(MINUTE, start_timestamp, end_timestamp) as timestamp_timestamp,"
+ " TIMESTAMPDIFF(MINUTE, start_timestamp, end_timestamp_ltz) as timestamp_timestamp_ltz,"
+ " TIMESTAMPDIFF(MINUTE, start_timestamp_ltz, end_timestamp) as timestamp_ltz_timestamp,"
+ " TIMESTAMPDIFF(MINUTE, start_timestamp_ltz, end_timestamp_ltz) as timestamp_ltz_timestamp_ltz" ,
"time_interval_unit='MINUTE'" )
. addTransform (
TIMESTAMPDIFF_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit,"
+ " TIMESTAMPDIFF(HOUR, start_timestamp, end_timestamp) as timestamp_timestamp,"
+ " TIMESTAMPDIFF(HOUR, start_timestamp, end_timestamp_ltz) as timestamp_timestamp_ltz,"
+ " TIMESTAMPDIFF(HOUR, start_timestamp_ltz, end_timestamp) as timestamp_ltz_timestamp,"
+ " TIMESTAMPDIFF(HOUR, start_timestamp_ltz, end_timestamp_ltz) as timestamp_ltz_timestamp_ltz" ,
"time_interval_unit='HOUR'" )
. addTransform (
TIMESTAMPDIFF_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit,"
+ " TIMESTAMPDIFF(DAY, start_timestamp, end_timestamp) as timestamp_timestamp,"
+ " TIMESTAMPDIFF(DAY, start_timestamp, end_timestamp_ltz) as timestamp_timestamp_ltz,"
+ " TIMESTAMPDIFF(DAY, start_timestamp_ltz, end_timestamp) as timestamp_ltz_timestamp,"
+ " TIMESTAMPDIFF(DAY, start_timestamp_ltz, end_timestamp_ltz) as timestamp_ltz_timestamp_ltz" ,
"time_interval_unit='DAY'" )
. addTransform (
TIMESTAMPDIFF_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit,"
+ " TIMESTAMPDIFF(MONTH, start_timestamp, end_timestamp) as timestamp_timestamp,"
+ " TIMESTAMPDIFF(MONTH, start_timestamp, end_timestamp_ltz) as timestamp_timestamp_ltz,"
+ " TIMESTAMPDIFF(MONTH, start_timestamp_ltz, end_timestamp) as timestamp_ltz_timestamp,"
+ " TIMESTAMPDIFF(MONTH, start_timestamp_ltz, end_timestamp_ltz) as timestamp_ltz_timestamp_ltz" ,
"time_interval_unit='MONTH'" )
. addTransform (
TIMESTAMPDIFF_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit,"
+ " TIMESTAMPDIFF(YEAR, start_timestamp, end_timestamp) as timestamp_timestamp,"
+ " TIMESTAMPDIFF(YEAR, start_timestamp, end_timestamp_ltz) as timestamp_timestamp_ltz,"
+ " TIMESTAMPDIFF(YEAR, start_timestamp_ltz, end_timestamp) as timestamp_ltz_timestamp,"
+ " TIMESTAMPDIFF(YEAR, start_timestamp_ltz, end_timestamp_ltz) as timestamp_ltz_timestamp_ltz" ,
"time_interval_unit='YEAR'" )
. addTimezone ( "UTC" )
. build ( ) ;
RegularEventOperatorTestHarness < PostTransformOperator , Event >
transformFunctionEventEventOperatorTestHarness =
RegularEventOperatorTestHarness . with ( transform , 1 ) ;
// Initialization
transformFunctionEventEventOperatorTestHarness . open ( ) ;
// Create table
CreateTableEvent createTableEvent =
new CreateTableEvent ( TIMESTAMPDIFF_DATA_TABLEID , TIMESTAMPDIFF_DATA_SCHEMA ) ;
transform . processElement ( new StreamRecord < > ( createTableEvent ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo (
new StreamRecord < > (
new CreateTableEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
EXPECTED_TIMESTAMPDIFF_DATA_SCHEMA ) ) ) ;
BinaryRecordDataGenerator recordDataGenerator =
new BinaryRecordDataGenerator (
( ( RowType ) TIMESTAMPDIFF_DATA_SCHEMA . toRowDataType ( ) ) ) ;
BinaryRecordDataGenerator recordDataGeneratorExpect =
new BinaryRecordDataGenerator (
( ( RowType ) EXPECTED_TIMESTAMPDIFF_DATA_SCHEMA . toRowDataType ( ) ) ) ;
// 1970-01-01 00:00:00 ~ 2025-01-01 00:00:00, Second: 1735689600
DataChangeEvent insertEvent1 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "1" ) ,
new BinaryStringData ( "SECOND" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 )
} ) ) ;
DataChangeEvent insertEventExpect1 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "1" ) ,
new BinaryStringData ( "SECOND" ) ,
1735689600 ,
1735689600 ,
1735689600 ,
1735689600
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent1 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect1 ) ) ;
// 1970-01-01 00:00:00 ~ 2025-01-01 00:00:00, Minute: 28928160
DataChangeEvent insertEvent2 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "2" ) ,
new BinaryStringData ( "MINUTE" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 )
} ) ) ;
DataChangeEvent insertEventExpect2 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "2" ) ,
new BinaryStringData ( "MINUTE" ) ,
28928160 ,
28928160 ,
28928160 ,
28928160
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent2 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect2 ) ) ;
// 1970-01-01 00:00:00 ~ 2025-01-01 00:00:00, Hour: 482136
DataChangeEvent insertEvent3 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "3" ) ,
new BinaryStringData ( "HOUR" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 )
} ) ) ;
DataChangeEvent insertEventExpect3 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "3" ) ,
new BinaryStringData ( "HOUR" ) ,
482136 ,
482136 ,
482136 ,
482136
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent3 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect3 ) ) ;
// 1970-01-01 00:00:00 ~ 2025-01-01 00:00:00, Day: 20089
DataChangeEvent insertEvent4 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "4" ) ,
new BinaryStringData ( "DAY" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 )
} ) ) ;
DataChangeEvent insertEventExpect4 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "4" ) ,
new BinaryStringData ( "DAY" ) ,
20089 ,
20089 ,
20089 ,
20089
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent4 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect4 ) ) ;
// 1970-01-01 00:00:00 ~ 2025-01-01 00:00:00, Month: 660
DataChangeEvent insertEvent5 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "5" ) ,
new BinaryStringData ( "MONTH" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 )
} ) ) ;
DataChangeEvent insertEventExpect5 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "5" ) ,
new BinaryStringData ( "MONTH" ) ,
660 ,
660 ,
660 ,
660
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent5 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect5 ) ) ;
// 1970-01-01 00:00:00 ~ 2025-01-01 00:00:00, Year: 660
DataChangeEvent insertEvent6 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "6" ) ,
new BinaryStringData ( "YEAR" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 )
} ) ) ;
DataChangeEvent insertEventExpect6 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "6" ) ,
new BinaryStringData ( "YEAR" ) ,
55 ,
55 ,
55 ,
55
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent6 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect6 ) ) ;
// 1970-01-01 00:00:00 ~ 9999-12-31 23:59:59, Year: 8029
DataChangeEvent insertEvent7 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "7" ) ,
new BinaryStringData ( "YEAR" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
TimestampData . fromMillis ( 253402271999000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 253402271999000L , 0 )
} ) ) ;
DataChangeEvent insertEventExpect7 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "7" ) ,
new BinaryStringData ( "YEAR" ) ,
8029 ,
8029 ,
8029 ,
8029
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent7 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect7 ) ) ;
// 1970-01-01 00:00:00 ~ 9999-12-31 23:59:59, Second: null ( > Integer.MAX_VALUE)
DataChangeEvent insertEvent8 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "8" ) ,
new BinaryStringData ( "SECOND" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
TimestampData . fromMillis ( 253402271999000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 253402271999000L , 0 )
} ) ) ;
DataChangeEvent insertEventExpect8 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "8" ) ,
new BinaryStringData ( "SECOND" ) ,
null ,
null ,
null ,
null
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent8 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect8 ) ) ;
// 1970-01-01 00:00:00 ~ null, Year: null
DataChangeEvent insertEvent9 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "9" ) ,
new BinaryStringData ( "YEAR" ) ,
TimestampData . fromMillis ( 0 , 0 ) ,
null ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
null
} ) ) ;
DataChangeEvent insertEventExpect9 =
DataChangeEvent . insertEvent (
TIMESTAMPDIFF_DATA_TABLEID ,
recordDataGeneratorExpect . generate (
new Object [ ] {
new BinaryStringData ( "9" ) ,
new BinaryStringData ( "YEAR" ) ,
null ,
null ,
null ,
null
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent9 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect9 ) ) ;
}
@Test
void testTimestampaddTransform ( ) throws Exception {
PostTransformOperator transform =
PostTransformOperator . newBuilder ( )
. addTransform (
TIMESTAMPADD_TABLEID . identifier ( ) ,
"col1, DATE_FORMAT(TIMESTAMPADD(SECOND, 1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as second_add,"
+ " DATE_FORMAT(TIMESTAMPADD(MINUTE, 1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as minute_add,"
+ " DATE_FORMAT(TIMESTAMPADD(HOUR, 1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as hour_add,"
+ " DATE_FORMAT(TIMESTAMPADD(DAY, 1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as day_add,"
+ " DATE_FORMAT(TIMESTAMPADD(MONTH, 1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as month_add,"
+ " DATE_FORMAT(TIMESTAMPADD(YEAR, 1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as year_add" ,
"col1='1'" )
. addTransform (
TIMESTAMPADD_TABLEID . identifier ( ) ,
"col1, DATE_FORMAT(TIMESTAMPADD(SECOND, -1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as second_add,"
+ " DATE_FORMAT(TIMESTAMPADD(MINUTE, -1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as minute_add,"
+ " DATE_FORMAT(TIMESTAMPADD(HOUR, -1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as hour_add,"
+ " DATE_FORMAT(TIMESTAMPADD(DAY, -1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as day_add,"
+ " DATE_FORMAT(TIMESTAMPADD(MONTH, -1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as month_add,"
+ " DATE_FORMAT(TIMESTAMPADD(YEAR, -1, TO_TIMESTAMP('2024-10-01 00:00:00')), 'yyyy-MM-dd HH:mm:ss') as year_add" ,
"col1='2'" )
. addTimezone ( "UTC" )
. build ( ) ;
RegularEventOperatorTestHarness < PostTransformOperator , Event >
transformFunctionEventEventOperatorTestHarness =
RegularEventOperatorTestHarness . with ( transform , 1 ) ;
// Initialization
transformFunctionEventEventOperatorTestHarness . open ( ) ;
// Create table
CreateTableEvent createTableEvent =
new CreateTableEvent ( TIMESTAMPADD_TABLEID , TIMESTAMPADD_SCHEMA ) ;
BinaryRecordDataGenerator recordDataGenerator =
new BinaryRecordDataGenerator ( ( ( RowType ) TIMESTAMPADD_SCHEMA . toRowDataType ( ) ) ) ;
// Insert
DataChangeEvent insertEvent =
DataChangeEvent . insertEvent (
TIMESTAMPADD_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "1" ) , null , null , null , null , null , null
} ) ) ;
DataChangeEvent insertEventExpect =
DataChangeEvent . insertEvent (
TIMESTAMPADD_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "1" ) ,
new BinaryStringData ( "2024-10-01 00:00:01" ) ,
new BinaryStringData ( "2024-10-01 00:01:00" ) ,
new BinaryStringData ( "2024-10-01 01:00:00" ) ,
new BinaryStringData ( "2024-10-02 00:00:00" ) ,
new BinaryStringData ( "2024-11-01 00:00:00" ) ,
new BinaryStringData ( "2025-10-01 00:00:00" )
} ) ) ;
transform . processElement ( new StreamRecord < > ( createTableEvent ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo (
new StreamRecord < > (
new CreateTableEvent ( TIMESTAMPADD_TABLEID , TIMESTAMPADD_SCHEMA ) ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect ) ) ;
DataChangeEvent insertEvent2 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "2" ) , null , null , null , null , null , null
} ) ) ;
DataChangeEvent insertEventExpect2 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "2" ) ,
new BinaryStringData ( "2024-09-30 23:59:59" ) ,
new BinaryStringData ( "2024-09-30 23:59:00" ) ,
new BinaryStringData ( "2024-09-30 23:00:00" ) ,
new BinaryStringData ( "2024-09-30 00:00:00" ) ,
new BinaryStringData ( "2024-09-01 00:00:00" ) ,
new BinaryStringData ( "2023-10-01 00:00:00" )
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent2 ) ) ;
Assertions . assertThat (
@ -1253,13 +1747,270 @@ public class PostTransformOperatorTest {
transformFunctionEventEventOperatorTestHarness . close ( ) ;
}
@Test
void testTimestampaddTransformData ( ) throws Exception {
PostTransformOperator transform =
PostTransformOperator . newBuilder ( )
. addTransform (
TIMESTAMPADD_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit, interval_value,"
+ " TIMESTAMPADD(SECOND, interval_value, time_point_timestamp) as time_point_timestamp,"
+ " TIMESTAMPADD(SECOND, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz" ,
"time_interval_unit='SECOND'" )
. addTransform (
TIMESTAMPADD_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit, interval_value,"
+ " TIMESTAMPADD(MINUTE, interval_value, time_point_timestamp) as time_point_timestamp,"
+ " TIMESTAMPADD(MINUTE, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz" ,
"time_interval_unit='MINUTE'" )
. addTransform (
TIMESTAMPADD_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit, interval_value,"
+ " TIMESTAMPADD(HOUR, interval_value, time_point_timestamp) as time_point_timestamp,"
+ " TIMESTAMPADD(HOUR, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz" ,
"time_interval_unit='HOUR'" )
. addTransform (
TIMESTAMPADD_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit, interval_value,"
+ " TIMESTAMPADD(DAY, interval_value, time_point_timestamp) as time_point_timestamp,"
+ " TIMESTAMPADD(DAY, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz" ,
"time_interval_unit='DAY'" )
. addTransform (
TIMESTAMPADD_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit, interval_value,"
+ " TIMESTAMPADD(MONTH, interval_value, time_point_timestamp) as time_point_timestamp,"
+ " TIMESTAMPADD(MONTH, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz" ,
"time_interval_unit='MONTH'" )
. addTransform (
TIMESTAMPADD_DATA_TABLEID . identifier ( ) ,
"col1, time_interval_unit, interval_value,"
+ " TIMESTAMPADD(YEAR, interval_value, time_point_timestamp) as time_point_timestamp,"
+ " TIMESTAMPADD(YEAR, interval_value, time_point_timestamp_ltz) as time_point_timestamp_ltz" ,
"time_interval_unit='YEAR'" )
. addTimezone ( "UTC" )
. build ( ) ;
RegularEventOperatorTestHarness < PostTransformOperator , Event >
transformFunctionEventEventOperatorTestHarness =
RegularEventOperatorTestHarness . with ( transform , 1 ) ;
// Initialization
transformFunctionEventEventOperatorTestHarness . open ( ) ;
// Create table
CreateTableEvent createTableEvent =
new CreateTableEvent ( TIMESTAMPADD_DATA_TABLEID , TIMESTAMPADD_DATA_SCHEMA ) ;
transform . processElement ( new StreamRecord < > ( createTableEvent ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo (
new StreamRecord < > (
new CreateTableEvent (
TIMESTAMPADD_DATA_TABLEID , TIMESTAMPADD_DATA_SCHEMA ) ) ) ;
BinaryRecordDataGenerator recordDataGenerator =
new BinaryRecordDataGenerator ( ( ( RowType ) TIMESTAMPADD_DATA_SCHEMA . toRowDataType ( ) ) ) ;
// 1970-01-01 00:00:00 + Second: 1735689600 = 2025-01-01 00:00:00
DataChangeEvent insertEvent1 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "1" ) ,
new BinaryStringData ( "SECOND" ) ,
1735689600 ,
TimestampData . fromMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
} ) ) ;
DataChangeEvent insertEventExpect1 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "1" ) ,
new BinaryStringData ( "SECOND" ) ,
1735689600 ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 ) ,
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent1 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect1 ) ) ;
// 1970-01-01 00:00:00 + Minute: 28928160 = 2025-01-01 00:00:00
DataChangeEvent insertEvent2 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "2" ) ,
new BinaryStringData ( "MINUTE" ) ,
28928160 ,
TimestampData . fromMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
} ) ) ;
DataChangeEvent insertEventExpect2 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "2" ) ,
new BinaryStringData ( "MINUTE" ) ,
28928160 ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 ) ,
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent2 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect2 ) ) ;
// 1970-01-01 00:00:00 + Hour: 482136 = 2025-01-01 00:00:00
DataChangeEvent insertEvent3 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "3" ) ,
new BinaryStringData ( "HOUR" ) ,
482136 ,
TimestampData . fromMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
} ) ) ;
DataChangeEvent insertEventExpect3 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "3" ) ,
new BinaryStringData ( "HOUR" ) ,
482136 ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 ) ,
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent3 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect3 ) ) ;
// 1970-01-01 00:00:00 + Day: 20089 = 2025-01-01 00:00:00
DataChangeEvent insertEvent4 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "4" ) ,
new BinaryStringData ( "DAY" ) ,
20089 ,
TimestampData . fromMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
} ) ) ;
DataChangeEvent insertEventExpect4 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "4" ) ,
new BinaryStringData ( "DAY" ) ,
20089 ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 ) ,
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent4 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect4 ) ) ;
// 1970-01-01 00:00:00 + Month: 660 = 2025-01-01 00:00:00
DataChangeEvent insertEvent5 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "5" ) ,
new BinaryStringData ( "MONTH" ) ,
660 ,
TimestampData . fromMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
} ) ) ;
DataChangeEvent insertEventExpect5 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "5" ) ,
new BinaryStringData ( "MONTH" ) ,
660 ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 ) ,
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent5 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect5 ) ) ;
// 1970-01-01 00:00:00 + Year: 55 = 2025-01-01 00:00:00
DataChangeEvent insertEvent6 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "6" ) ,
new BinaryStringData ( "YEAR" ) ,
55 ,
TimestampData . fromMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
} ) ) ;
DataChangeEvent insertEventExpect6 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "6" ) ,
new BinaryStringData ( "YEAR" ) ,
55 ,
TimestampData . fromMillis ( 1735689600000L , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 1735689600000L , 0 ) ,
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent6 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect6 ) ) ;
// 1970-01-01 00:00:00 + Year: null = null
DataChangeEvent insertEvent7 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "7" ) ,
new BinaryStringData ( "YEAR" ) ,
null ,
TimestampData . fromMillis ( 0 , 0 ) ,
LocalZonedTimestampData . fromEpochMillis ( 0 , 0 ) ,
} ) ) ;
DataChangeEvent insertEventExpect7 =
DataChangeEvent . insertEvent (
TIMESTAMPADD_DATA_TABLEID ,
recordDataGenerator . generate (
new Object [ ] {
new BinaryStringData ( "7" ) ,
new BinaryStringData ( "YEAR" ) ,
null ,
null ,
null ,
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent7 ) ) ;
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect7 ) ) ;
}
@Test
void testTimezoneTransform ( ) throws Exception {
PostTransformOperator transform =
PostTransformOperator . newBuilder ( )
. addTransform (
TIMEZONE_TABLEID . identifier ( ) ,
"col1, DATE_FORMAT(TO_TIMESTAMP('2024-08-01 00:00:00'), 'yyyy-MM-dd HH:mm:ss') as datetime" ,
"col1, DATE_FORMAT(TO_TIMESTAMP('2024-08-01 00:00:00'), 'yyyy-MM-dd HH:mm:ss') as datetime _value ",
null )
. addTimezone ( "UTC" )
. build ( ) ;
@ -1296,7 +2047,6 @@ public class PostTransformOperatorTest {
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect ) ) ;
transformFunctionEventEventOperatorTestHarness . close ( ) ;
}
@Test
@ -1402,11 +2152,11 @@ public class PostTransformOperatorTest {
+ ",cast(castBoolean as tinyint) as castTinyint"
+ ",cast(castBoolean as smallint) as castSmallint"
+ ",cast(castBoolean as bigint) as castBigint"
+ ",cast (castBoolean as float) as cast Float"
+ ",cast (castBoolean as double) as cast Double"
+ ",cast Float"
+ ",cast Double"
+ ",cast(castBoolean as char) as castChar"
+ ",cast(castBoolean as varchar) as castVarchar"
+ ",cast (castBoolean as DECIMAL(4,2)) as cast Decimal"
+ ",cast Decimal"
+ ", castTimestamp" ,
"col1 = '3'" )
. addTransform (
@ -1638,11 +2388,11 @@ public class PostTransformOperatorTest {
new Byte ( "1" ) ,
new Short ( "1" ) ,
new Long ( 1 ) ,
new Float ( 1.0f ) ,
new Double ( 1.0d ) ,
null ,
null ,
new BinaryStringData ( "true" ) ,
new BinaryStringData ( "true" ) ,
DecimalData . fromBigDecimal ( new BigDecimal ( 1.0 ) , 4 , 2 ) ,
null ,
null
} ) ) ;
transform . processElement ( new StreamRecord < > ( insertEvent3 ) ) ;
@ -1930,7 +2680,6 @@ public class PostTransformOperatorTest {
Assertions . assertThat (
transformFunctionEventEventOperatorTestHarness . getOutputRecords ( ) . poll ( ) )
. isEqualTo ( new StreamRecord < > ( insertEventExpect10 ) ) ;
transformFunctionEventEventOperatorTestHarness . close ( ) ;
}
@Test
@ -2185,7 +2934,7 @@ public class PostTransformOperatorTest {
testExpressionConditionTransform (
"TO_TIMESTAMP('1970-01-01 00:00:00') = TO_TIMESTAMP('1970-01-01', 'yyyy-MM-dd')" ) ;
testExpressionConditionTransform (
"TIMESTAMP _ DIFF(' DAY' , TO_TIMESTAMP('1970-01-01 00:00:00'), TO_TIMESTAMP('1970-01-02 00:00:00')) = 1") ;
"TIMESTAMP DIFF(DAY, TO_TIMESTAMP('1970-01-01 00:00:00'), TO_TIMESTAMP('1970-01-02 00:00:00')) = 1") ;
testExpressionConditionTransform ( "2 between 1 and 3" ) ;
testExpressionConditionTransform ( "4 not between 1 and 3" ) ;
testExpressionConditionTransform ( "2 in (1, 2, 3)" ) ;