4040import static java .util .Collections .singletonMap ;
4141import static java .util .concurrent .TimeUnit .MILLISECONDS ;
4242import static java .util .concurrent .TimeUnit .SECONDS ;
43- import static org .apache .kafka .common .config .AbstractConfig .CONFIG_PROVIDERS_CONFIG ;
4443import static org .apache .kafka .connect .runtime .ConnectorConfig .KEY_CONVERTER_CLASS_CONFIG ;
4544import static org .apache .kafka .connect .runtime .ConnectorConfig .VALUE_CONVERTER_CLASS_CONFIG ;
4645
@@ -63,7 +62,7 @@ public final class QuestDBSinkConnectorEmbeddedTest {
6362 .withEnv ("JAVA_OPTS" , "-Djava.locale.providers=JRE,SPI" );
6463
6564 @ BeforeEach
66- public void setUp () throws IOException {
65+ public void setUp () {
6766 topicName = newTopicName ();
6867 JsonConverter jsonConverter = new JsonConverter ();
6968 jsonConverter .configure (singletonMap (ConverterConfig .TYPE_CONFIG , ConverterType .VALUE .getName ()));
@@ -120,7 +119,7 @@ public void testDesignatedTimestamp_noSchema_unixEpochMillis() {
120119 connect .kafka ().createTopic (topicName , 1 );
121120 Map <String , String > props = baseConnectorProps (topicName );
122121 props .put ("value.converter.schemas.enable" , "false" );
123- props .put (QuestDBSinkConnectorConfig .DESIGNATED_TIMESTAMP_COLUMN_NAME , "birth" );
122+ props .put (QuestDBSinkConnectorConfig .DESIGNATED_TIMESTAMP_COLUMN_NAME_CONFIG , "birth" );
124123 connect .configureConnector (CONNECTOR_NAME , props );
125124 assertConnectorTaskRunningEventually ();
126125
@@ -141,7 +140,7 @@ public void testDesignatedTimestamp_noSchema_dateTransform_fromStringToTimestamp
141140 props .put ("transforms.convert_birth.target.type" , "Timestamp" );
142141 props .put ("transforms.convert_birth.field" , "birth" );
143142 props .put ("transforms.convert_birth.format" , "yyyy-MM-dd'T'HH:mm:ss.SSSX" );
144- props .put (QuestDBSinkConnectorConfig .DESIGNATED_TIMESTAMP_COLUMN_NAME , "birth" );
143+ props .put (QuestDBSinkConnectorConfig .DESIGNATED_TIMESTAMP_COLUMN_NAME_CONFIG , "birth" );
145144 connect .configureConnector (CONNECTOR_NAME , props );
146145 assertConnectorTaskRunningEventually ();
147146
@@ -156,7 +155,7 @@ public void testDesignatedTimestamp_noSchema_dateTransform_fromStringToTimestamp
156155 public void testDesignatedTimestamp_withSchema () {
157156 connect .kafka ().createTopic (topicName , 1 );
158157 Map <String , String > props = baseConnectorProps (topicName );
159- props .put (QuestDBSinkConnectorConfig .DESIGNATED_TIMESTAMP_COLUMN_NAME , "birth" );
158+ props .put (QuestDBSinkConnectorConfig .DESIGNATED_TIMESTAMP_COLUMN_NAME_CONFIG , "birth" );
160159 connect .configureConnector (CONNECTOR_NAME , props );
161160 assertConnectorTaskRunningEventually ();
162161 Schema schema = SchemaBuilder .struct ().name ("com.example.Person" )
@@ -184,6 +183,39 @@ public void testDesignatedTimestamp_withSchema() {
184183 "select * from " + topicName );
185184 }
186185
186+ @ Test
187+ public void testDoNotIncludeKey () {
188+ connect .kafka ().createTopic (topicName , 1 );
189+ Map <String , String > props = baseConnectorProps (topicName );
190+ props .put (QuestDBSinkConnectorConfig .DESIGNATED_TIMESTAMP_COLUMN_NAME_CONFIG , "birth" );
191+ props .put (QuestDBSinkConnectorConfig .INCLUDE_KEY_CONFIG , "false" );
192+ connect .configureConnector (CONNECTOR_NAME , props );
193+ assertConnectorTaskRunningEventually ();
194+ Schema schema = SchemaBuilder .struct ().name ("com.example.Person" )
195+ .field ("firstname" , Schema .STRING_SCHEMA )
196+ .field ("lastname" , Schema .STRING_SCHEMA )
197+ .field ("birth" , Timestamp .SCHEMA )
198+ .build ();
199+
200+ java .util .Date birth = new Calendar .Builder ()
201+ .setTimeZone (TimeZone .getTimeZone ("UTC" ))
202+ .setDate (2022 , 9 , 23 ) // note: month is 0-based
203+ .setTimeOfDay (13 , 53 , 59 , 123 )
204+ .build ().getTime ();
205+
206+ Struct struct = new Struct (schema )
207+ .put ("firstname" , "John" )
208+ .put ("lastname" , "Doe" )
209+ .put ("birth" , birth );
210+
211+
212+ connect .kafka ().produce (topicName , "key" , new String (converter .fromConnectData (topicName , schema , struct )));
213+
214+ QuestDBUtils .assertSqlEventually (questDBContainer , "\" firstname\" ,\" lastname\" ,\" timestamp\" \r \n "
215+ + "\" John\" ,\" Doe\" ,\" 2022-10-23T13:53:59.123000Z\" \r \n " ,
216+ "select * from " + topicName );
217+ }
218+
187219 @ Test
188220 public void testJsonNoSchema () {
189221 connect .kafka ().createTopic (topicName , 1 );
0 commit comments