sqlite3的Kafka JDBC源连接器时间戳模式失败
我试图用sqlite中的两个表建立一个数据库。有一次,我的表有一个timestamp列。我试图实现时间戳模式来捕获数据库中的增量更改。Kafka connect失败,出现以下错误:sqlite3的Kafka JDBC源连接器时间戳模式失败,sqlite,apache-kafka,apache-kafka-connect,confluent-platform,Sqlite,Apache Kafka,Apache Kafka Connect,Confluent Platform,我试图用sqlite中的两个表建立一个数据库。有一次,我的表有一个timestamp列。我试图实现时间戳模式来捕获数据库中的增量更改。Kafka connect失败,出现以下错误: ERROR Failed to get current time from DB using Sqlite and query 'SELECT CURRENT_TIMESTAMP' (io.confluent.connect.jdbc.dialect.SqliteDatabaseDialect:471) jav
ERROR Failed to get current time from DB using Sqlite and query 'SELECT
CURRENT_TIMESTAMP'
(io.confluent.connect.jdbc.dialect.SqliteDatabaseDialect:471)
java.sql.SQLException: Error parsing time stamp
Caused by: java.text.ParseException: Unparseable date: "2019-02-05 02:05:29"
does not match (\p{Nd}++)\Q-\E(\p{Nd}++)\Q-\E(\p{Nd}++)\Q
\E(\p{Nd}++)\Q:\E(\p{Nd}++)\Q:\E(\p{Nd}++)\Q.\E(\p{Nd}++)
非常感谢你的帮助
配置:
name=test-query-sqlite-jdbc-autoincrement
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=1
connection.url=jdbc:sqlite:employee.db
query=SELECT users.id, users.name, transactions.timestamp, transactions.payment_type FROM users JOIN transactions ON (users.id = transactions.user_id)
mode=timestamp
timestamp.column.name=timestamp
topic.prefix=test-joined
DDL:
我已经复制了这个,并且它已经作为JDBC源代码连接器的一个问题记录下来。您可以在此处监视它:如果“timestamp”列的值采用“UNIX timestamp”格式,则kafka connect jdbc连接器可以轻松检测时间戳中的更改
sqlite> CREATE TABLE transact(timestamp TIMESTAMP DEFAULT (STRFTIME('%s', 'now')) not null,
...> id integer primary key not null,
...> payment_type text not null);
sqlite>
这些值可以插入为:
sqlite> INSERT INTO transact(timestamp,payment_type,id) VALUES (STRFTIME('%s', 'now'),'cash',1);
然后,kafka jdbc源连接器会检测到与时间戳相关的更改,并且可以按如下方式使用这些更改:
kafka-console-consumer --bootstrap-server localhost:9092 --topic jdbc-transact --from-beginning
{"timestamp":1562321516,"id":2,"payment_type":"card"}
{"timestamp":1562321790,"id":1,"payment_type":"online"}
您可以共享表DDL和连接器配置吗?根据error@cricket_007在引导过程中,从io.confluent.connect.jdbc.Dialogue.SqliteDatabaseDialogue内部类中的内部查询生成错误。对于自定义查询,我已包含毫秒精度。@RobinMoffatt DDL-创建表事务(id integer主键不为null,付款类型文本不为null,时间戳日期时间默认值(STRFTIME(“%Y-%m-%d%H:%m:%f”,“NOW”)),用户id int不为null,约束fk外键(用户id)引用用户(id))@DDeveloper请使用DDL语句和连接器配置更新您的问题。谢谢
kafka-console-consumer --bootstrap-server localhost:9092 --topic jdbc-transact --from-beginning
{"timestamp":1562321516,"id":2,"payment_type":"card"}
{"timestamp":1562321790,"id":1,"payment_type":"online"}