Colin Williams
01/17/2023, 6:21 PMorg.apache.flink.table.api.ValidationException: Column types of query result and sink for 'temporaryCatalog.default.enrichmentOut' do not match.
Cause: Different number of columns.
Query schema: [id: STRING NOT NULL, enrichment: STRING NOT NULL, ts: TIMESTAMP(3) *ROWTIME*]
Sink schema: [id: STRING, status: STRING, enrichment: STRING, ts: TIMESTAMP(3)]
Based on https://cwiki.apache.org/confluence/display/FLINK/FLIP-66%3A+Support+time+attribute+in+SQL+DDL
I think I need to set a watermark strategy and perhaps rowtime field for my table job. Can I set this on the Table schema below? Is there a flink doc that shows this or would someone please kindly provide the syntax for doing this with the Table API?
Schema.newBuilder()
.column("id", DataTypes.STRING().notNull())
.column("status", DataTypes.STRING().notNull())
.column("enrichment", DataTypes.STRING().notNull())
.column("ts",DataTypes.TIMESTAMP(3).bridgedTo(java.sql.Timestamp.class))
.primaryKey("id")
.watermark("ts","ts")
.build();Martijn Visser
01/17/2023, 6:24 PMColin Williams
01/17/2023, 6:25 PMMartijn Visser
01/17/2023, 6:26 PMColin Williams
01/17/2023, 6:27 PMColin Williams
01/17/2023, 6:30 PMColin Williams
01/17/2023, 6:30 PMColin Williams
01/17/2023, 6:31 PMColin Williams
01/17/2023, 6:32 PMMartijn Visser
01/17/2023, 6:39 PMColin Williams
01/17/2023, 6:42 PMColin Williams
01/17/2023, 6:43 PMorg.apache.flink.table.api.ValidationException: Column types of query result and sink for 'temporaryCatalog.default.enrichmentOut' do not match.
Cause: Different number of columns.
Query schema: [id: STRING NOT NULL, status: STRING, ts: TIMESTAMP(3) *ROWTIME*, id0: STRING NOT NULL, enrichment: STRING NOT NULL, ts0: TIMESTAMP(3) *ROWTIME*]
Sink schema: [id: STRING, status: STRING, enrichment: STRING, ts: TIMESTAMP(3)]Colin Williams
01/17/2023, 6:44 PMColin Williams
01/17/2023, 6:46 PMColin Williams
01/17/2023, 6:48 PMColin Williams
01/17/2023, 6:54 PMpublic static final String JOIN_QUERY_2 = "INSERT INTO "+ENR_DST_TABLE_PATH+" SELECT id0,status,ts,enrichment FROM "+SRC_TABLE_PATH+ " JOIN "+ENR_SRC_TABLE_PATH+" FOR SYSTEM_TIME AS OF "+SRC_TABLE_PATH+".ts"+" ON "+SRC_TABLE_PATH+".id ="+ENR_SRC_TABLE_PATH+".id";Colin Williams
01/17/2023, 6:57 PMColin Williams
01/17/2023, 7:05 PMorg.apache.flink.table.api.ValidationException: Column types of query result and sink for 'temporaryCatalog.default.enrichmentOut' do not match.
Cause: Different number of columns.
Query schema: [id: STRING NOT NULL, status: STRING, ts: TIMESTAMP(3) *ROWTIME*, id0: STRING NOT NULL, enrichment: STRING NOT NULL, ts0: TIMESTAMP(3) *ROWTIME*]
Sink schema: [id: STRING, status: STRING, enrichment: STRING, ts: TIMESTAMP(3)]Colin Williams
01/17/2023, 7:06 PMColin Williams
01/17/2023, 7:08 PMColin Williams
01/17/2023, 8:19 PM*ROWTIME that came as the hypothesis of the original postColin Williams
01/17/2023, 8:21 PMorg.apache.flink.table.api.ValidationException: Column types of query result and sink for 'temporaryCatalog.default.enrichmentOut' do not match.
Cause: Incompatible types for sink column 'enrichment' at position 2.
Query schema: [id: STRING NOT NULL, status: STRING, ts: TIMESTAMP(3) *ROWTIME*, enrichment: STRING NOT NULL]
Sink schema: [id: STRING, status: STRING, enrichment: STRING, ts: TIMESTAMP(3)]Martijn Visser
01/17/2023, 8:22 PMenrichment should also support NOT NULL for the sink?Colin Williams
01/17/2023, 8:23 PMMartijn Visser
01/17/2023, 8:24 PMSink schema: [id: STRING, status: STRING, enrichment: STRING, ts: TIMESTAMP(3)]
That doesn't, right?Martijn Visser
01/17/2023, 8:25 PMColin Williams
01/17/2023, 8:29 PMColin Williams
01/17/2023, 11:09 PM*ROWTIME missing in the output schema. Otherwise if you're correct then it's ignoring the output schema fields that I have shown I'm explicitly setting to null. It's a loss to me because I'm writing my query like the example.
https://github.com/ververica/flink-sql-cookbook/blob/main/joins/03_kafka_join/03_kafka_join.mdColin Williams
01/17/2023, 11:24 PMexecuteSQL with`.print()` would cause this. But still not sure why I cannot execute the query without print() https://github.com/apple-corps/recipes/blob/14d0a7d51ff9cddbd9550d7efe3b0edee85948[…]/table-example/src/main/java/com/immerok/cookbook/TableJob.javaMartijn Visser
01/18/2023, 1:51 PMBut still not sure why I cannot execute the query withoutYou should, https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/insert/ and it's also used numerous times in Flink codebase itselfprint()
Martijn Visser
01/18/2023, 1:54 PMColin Williams
01/18/2023, 2:04 PMrecipes/table-example:table-example -$ mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.immerok:cookbook-table-example >-----------------
[INFO] Building Flink Cookbook Recipe - Table Example 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ cookbook-table-example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ cookbook-table-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /home/cwilliams/code/recipes/table-example/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cookbook-table-example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ cookbook-table-example ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /home/cwilliams/code/recipes/table-example/target/test-classes
[INFO] /home/cwilliams/code/recipes/table-example/src/test/java/com/immerok/cookbook/CookbookKafkaCluster.java: Some input files use unchecked or unsafe operations.
[INFO] /home/cwilliams/code/recipes/table-example/src/test/java/com/immerok/cookbook/CookbookKafkaCluster.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ cookbook-table-example ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TableJobTest
06:02:53,475 INFO org.apache.flink.runtime.taskexecutor.TaskExecutorResourceUtils [] - The configuration option taskmanager.cpu.cores required for local execution is not set, setting it to the maximal possible value.
06:02:53,477 INFO org.apache.flink.runtime.taskexecutor.TaskExecutorResourceUtils [] - The configuration option taskmanager.memory.task.heap.size required for local execution is not set, setting it to the maximal possible value.
06:02:53,477 INFO org.apache.flink.runtime.taskexecutor.TaskExecutorResourceUtils [] - The configuration option taskmanager.memory.task.off-heap.size required for local execution is not set, setting it to the maximal possible value.
06:02:53,478 INFO org.apache.flink.runtime.taskexecutor.TaskExecutorResourceUtils [] - The configuration option taskmanager.memory.network.min required for local execution is not set, setting it to its default value 64 mb.
06:02:53,478 INFO org.apache.flink.runtime.taskexecutor.TaskExecutorResourceUtils [] - The configuration option taskmanager.memory.network.max required for local execution is not set, setting it to its default value 64 mb.
06:02:53,485 INFO org.apache.flink.runtime.minicluster.MiniCluster [] - Starting Flink Mini Cluster
06:02:53,489 INFO org.apache.flink.runtime.minicluster.MiniCluster [] - Starting Metrics Registry
06:02:53,513 INFO org.apache.flink.runtime.metrics.MetricRegistryImpl org.apache.flink.runtime.taskexecutor.DefaultJobLeaderService [] - Stop job leader service.
06:02:55,918 INFO org.apache.flink.runtime.state.TaskExecutorLocalStateStoresManager [] - Shutting down TaskExecutorLocalStateStoresManager.
06:02:55,919 INFO org.apache.flink.runtime.io.disk.FileChannelManagerImpl [] - FileChannelManager removed spill file directory /tmp/junit2307088322128074339/junit17902656541890378625/flink-io-d8a12e15-1482-48a8-9664-0f474bd4e400
06:02:55,919 INFO org.apache.flink.runtime.io.network.NettyShuffleEnvironment [] - Shutting down the network environment and its components.
06:02:55,920 INFO org.apache.flink.runtime.io.disk.FileChannelManagerImpl [] - FileChannelManager removed spill file directory /tmp/junit2307088322128074339/junit17902656541890378625/flink-netty-shuffle-69ee3243-23a5-4dd5-afac-ced686ee553f
06:02:55,920 INFO org.apache.flink.runtime.taskexecutor.KvStateService [] - Shutting down the kvState service and its components.
06:02:55,921 INFO org.apache.flink.runtime.taskexecutor.DefaultJobLeaderService [] - Stop job leader service.
06:02:55,921 INFO org.apache.flink.runtime.filecache.FileCache [] - removed file cache directory /tmp/junit2307088322128074339/junit17902656541890378625/flink-dist-cache-0552221a-e96b-47b2-b00e-ab3b3dffd5be
06:02:55,921 INFO org.apache.flink.runtime.taskexecutor.TaskExecutor [] - Stopped TaskExecutor <akka://flink/user/rpc/taskmanager_0>.
06:02:55,923 INFO org.apache.flink.runtime.resourcemanager.StandaloneResourceManager [] - Shut down cluster because application is in CANCELED, diagnostics DispatcherResourceManagerComponent has been closed..
06:02:55,923 INFO org.apache.flink.runtime.entrypoint.component.DispatcherResourceManagerComponent [] - Closing components.
06:02:55,924 INFO org.apache.flink.runtime.dispatcher.runner.SessionDispatcherLeaderProcess [] - Stopping SessionDispatcherLeaderProcess.
06:02:55,924 INFO org.apache.flink.runtime.dispatcher.StandaloneDispatcher [] - Stopping dispatcher <akka://flink/user/rpc/dispatcher_2>.
06:02:55,924 INFO org.apache.flink.runtime.dispatcher.StandaloneDispatcher [] - Stopping all currently running jobs of dispatcher <akka://flink/user/rpc/dispatcher_2>.
06:02:55,924 INFO org.apache.flink.runtime.resourcemanager.ResourceManagerServiceImpl [] - Stopping resource manager service.
06:02:55,924 INFO org.apache.flink.runtime.dispatcher.StandaloneDispatcher [] - Stopped dispatcher <akka://flink/user/rpc/dispatcher_2>.
06:02:55,924 INFO org.apache.flink.runtime.resourcemanager.slotmanager.DeclarativeSlotManager [] - Closing the slot manager.
06:02:55,925 INFO org.apache.flink.runtime.resourcemanager.slotmanager.DeclarativeSlotManager [] - Suspending the slot manager.
06:02:55,926 INFO org.apache.flink.runtime.rpc.akka.AkkaRpcService [] - Stopping Akka RPC service.
06:02:55,950 INFO org.apache.flink.runtime.rpc.akka.AkkaRpcService [] - Stopping Akka RPC service.
06:02:55,950 INFO org.apache.flink.runtime.rpc.akka.AkkaRpcService [] - Stopped Akka RPC service.
06:02:55,955 INFO org.apache.flink.runtime.blob.PermanentBlobCache [] - Shutting down BLOB cache
06:02:55,956 INFO org.apache.flink.runtime.blob.TransientBlobCache [] - Shutting down BLOB cache
06:02:55,956 INFO org.apache.flink.runtime.blob.BlobServer [] - Stopped BLOB server at 0.0.0.0:34419
06:02:55,956 INFO org.apache.flink.runtime.rpc.akka.AkkaRpcService [] - Stopped Akka RPC service.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.639 s <<< FAILURE! - in TableJobTest
[ERROR] testExecuteSQL Time elapsed: 1.814 s <<< ERROR!
org.apache.flink.table.api.ValidationException:
Column types of query result and sink for 'temporaryCatalog.default.enrichmentOut' do not match.
Cause: Incompatible types for sink column 'enrichment' at position 2.
Query schema: [id: STRING NOT NULL, status: STRING NOT NULL, ts: TIMESTAMP(3) *ROWTIME*, enrichment: STRING NOT NULL]
Sink schema: [id: STRING, status: STRING, enrichment: STRING, ts: TIMESTAMP(3)]
at TableJobTest.testExecuteSQL(TableJobTest.java:83)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] TableJobTest.testExecuteSQL:83 » Validation Column types of query result and s...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.531 s
[INFO] Finished at: 2023-01-18T06:02:56-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project cookbook-table-example: There are test failures.
[ERROR]
[ERROR] Please refer to /home/cwilliams/code/recipes/table-example/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] <http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException>Colin Williams
01/18/2023, 2:05 PMtable-example 130$ git log -1
commit e4b0011b6842109d28688560d1e4fb82581e3292 (HEAD -> table-example, origin/table-example)
Author: Colin Williams <Colin Williams>
Date: Tue Jan 17 15:32:43 2023 -0800
iterated between kafka and kafka-upsert. issue still existsColin Williams
01/18/2023, 2:06 PMColin Williams
01/18/2023, 2:11 PMQuery schema: [id: STRING NOT NULL, status: STRING NOT NULL, ts: TIMESTAMP(3) *ROWTIME*, enrichment: STRING NOT NULL]
Sink schema: [id: STRING, status: STRING, enrichment: STRING, ts: TIMESTAMP(3)]Colin Williams
01/18/2023, 2:12 PMNOT NULL which is set in the "Sink Schema" for all the fields, or that it's the issue with TIMESTAMP(3) missing *ROWTIME*Colin Williams
01/18/2023, 2:14 PMColin Williams
01/18/2023, 2:17 PMColin Williams
01/18/2023, 2:24 PMColin Williams
01/18/2023, 2:25 PMColin Williams
01/18/2023, 2:26 PMgit status
On branch table-example
Your branch is up to date with 'origin/table-example'.
nothing to commit, working tree cleanColin Williams
01/18/2023, 2:27 PMMartijn Visser
01/18/2023, 2:35 PMNot sure what build error you see. Would you share it?Local Maven artifact was corrupt because I've been building new Flink Shaded versions locally 🙈
Martijn Visser
01/18/2023, 2:36 PMenrichment definition that causes issues
Column types of query result and sink for 'temporaryCatalog.default.enrichmentOut' do not match.
Cause: Incompatible types for sink column 'enrichment' at position 2.
Colin Williams
01/18/2023, 2:46 PMMartijn Visser
01/18/2023, 2:46 PMMartijn Visser
01/18/2023, 2:46 PMColin Williams
01/18/2023, 2:49 PMMartijn Visser
01/18/2023, 2:49 PMColin Williams
01/18/2023, 2:55 PMMartijn Visser
01/18/2023, 2:56 PMColin Williams
01/18/2023, 3:07 PMColin Williams
01/18/2023, 3:10 PMColin Williams
01/19/2023, 9:59 PM