Stan Hsu
01/03/2024, 6:59 AMavro-confluent, but get some error and can't know how to deal, anyone help? thanks
CREATE TABLE kafka_event (
`kafka_key_id` VARCHAR NOT NULL,
`id` VARCHAR NOT NULL,
`scope` VARCHAR NOT NULL,
`distinct_id` VARCHAR NOT NULL,
`event_name` VARCHAR NOT NULL,
`event_category` VARCHAR,
`event_ts` BIGINT NOT NULL,
`client_sent_ts` BIGINT NOT NULL,
`server_received_ts` BIGINT NOT NULL,
`event_data` VARCHAR,
`page_name` VARCHAR,
`page_referer` VARCHAR,
`page_component` VARCHAR,
`screen_width` INT NOT NULL,
`screen_height` INT NOT NULL,
`http_domain` VARCHAR NOT NULL,
`http_search` VARCHAR,
`http_referer` VARCHAR,
`http_cookie` VARCHAR,
`url_path` VARCHAR NOT NULL,
`user_agent` VARCHAR NOT NULL,
`ip` VARCHAR,
`user_id` VARCHAR,
`language` VARCHAR,
`tz_identifier` VARCHAR,
`merchant_id` VARCHAR NOT NULL,
`session_id` VARCHAR,
`channel_id` VARCHAR,
`browser_version` VARCHAR,
`is_mobile` BOOLEAN,
`proc_time` AS PROCTIME(),
`_kafka_at` TIMESTAMP_LTZ(3) METADATA FROM 'timestamp'
) WITH (
'connector' = 'kafka',
'properties.bootstrap.servers' = '******.ap-southeast-1.aws.confluent.cloud:9092',
'properties.security.protocol' = 'SASL_SSL',
'properties.sasl.mechanism' = 'PLAIN',
'properties.sasl.jaas.config' = 'org.apache.flink.kafka.shaded.org.apache.kafka.common.security.plain.PlainLoginModule required username="******" password="="******"',
'properties.auto.offset.reset' = 'latest',
'properties.group.id' = 'flink-default',
'properties.client.id' = 'flink',
'scan.startup.mode' = 'latest-offset',
'topic' = 'event.web',
'key.avro-confluent.basic-auth.user-info' = '*****:'*****',
'key.avro-confluent.basic-auth.credentials-source' = 'USER_INFO',
'key.format' = 'avro-confluent',
'key.avro-confluent.url' = 'https://*****.ap-southeast-1.aws.confluent.cloud',
'key.fields' = 'kafka_key_id',
'key.fields-prefix' = 'kafka_key_',
'key.avro-confluent.properties.auto.register.schemas' = 'false',
'key.avro-confluent.properties.use.latest.version' = 'true',
'value.avro-confluent.basic-auth.user-info' = '******:*******',
'value.format' = 'avro-confluent',
'value.avro-confluent.url' = 'https://******.ap-southeast-1.aws.confluent.cloud',
'value.avro-confluent.basic-auth.credentials-source' = 'USER_INFO',
'value.fields-include' = 'EXCEPT_KEY',
'value.avro-confluent.properties.auto.register.schemas' = 'false',
'value.avro-confluent.properties.use.latest.version' = 'true',
'value.avro-confluent.properties.latest.compatibility.strict' = 'false'
);
error:
Caused by: java.io.IOException: Failed to deserialize consumer record ConsumerRecord(topic = event.web, partition = 5, leaderEpoch = 87, offset = 182253, CreateTime = 1704264852754, serialized key size = 38, serialized value size = 536, headers = RecordHeaders(headers = [], isReadOnly = false), key = [B@297064ae, value = [B@4eb05b10).
at org.apache.flink.connector.kafka.source.reader.deserializer.KafkaDeserializationSchemaWrapper.deserialize(KafkaDeserializationSchemaWrapper.java:57)
at org.apache.flink.connector.kafka.source.reader.KafkaRecordEmitter.emitRecord(KafkaRecordEmitter.java:53)
... 15 more
Caused by: java.io.IOException: Failed to deserialize Avro record.
at org.apache.flink.formats.avro.AvroRowDataDeserializationSchema.deserialize(AvroRowDataDeserializationSchema.java:106)
at org.apache.flink.formats.avro.AvroRowDataDeserializationSchema.deserialize(AvroRowDataDeserializationSchema.java:46)
at org.apache.flink.api.common.serialization.DeserializationSchema.deserialize(DeserializationSchema.java:82)
at org.apache.flink.streaming.connectors.kafka.table.DynamicKafkaDeserializationSchema.deserialize(DynamicKafkaDeserializationSchema.java:130)
at org.apache.flink.connector.kafka.source.reader.deserializer.KafkaDeserializationSchemaWrapper.deserialize(KafkaDeserializationSchemaWrapper.java:54)
... 16 more
Caused by: java.lang.ArrayIndexOutOfBoundsExceptionYuval Itzchakov
01/03/2024, 7:27 AMStan Hsu
01/03/2024, 7:43 AMevent.web, partition = 5, offset = 182253
message value
{
"id": "5e526126*********142b",
"scope": "shop",
"distinct_id": "5bc1cb32-e7*********-dde06a7d3db7",
"event_name": "View",
"event_category": "",
"event_ts": 1704264852748,
"client_sent_ts": 1704264852748,
"server_received_ts": 1704264852754,
"event_data": "{\"cart_id\": \"1060199\", \"cents\": 1, \"currency_iso\": \"TWD\", \"tracker_hd\": true}",
"page_name": null,
"page_referer": null,
"page_component": null,
"screen_width": 0,
"screen_height": 0,
"http_domain": "https://*****************nestg.com",
"http_search": "",
"http_referer": "https://*****************nestg.com/cart",
"http_cookie": "5bc1cb32*********06a7d3db7",
"url_path": "/checkout",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"ip": "157.119.232.36",
"user_id": "64902*********192ab1",
"language": "zh-hant",
"tz_identifier": null,
"merchant_id": "63427d*********81d73d",
"session_id": null,
"channel_id": null,
"browser_version": null,
"is_mobile": null
}
I think it follows the schema described in my Flink table, so I can't figure out what the problem is.
thanksYuval Itzchakov
01/03/2024, 8:12 AMkafka_key_id, although it’s a mandatory not null fieldYuval Itzchakov
01/03/2024, 8:13 AMStan Hsu
01/03/2024, 8:13 AM'key.fields' = 'kafka_key_id',
'key.fields-prefix' = 'kafka_key_',Stan Hsu
01/03/2024, 8:14 AM{
"fields": [
{
"doc": "Generated by API",
"name": "id",
"type": "string"
},
{
"doc": "Product platform type (snake case) (case sensitive)",
"name": "scope",
"type": "string"
},
{
"doc": "If no distinct_id is provided by the user, the API will generate a unique identifier and return it. Clients should store and use this generated distinct_id for tracking and identifying events.",
"name": "distinct_id",
"type": "string"
},
{
"doc": "Event name: Category+Action (CapitalCamelCase) (case sensitive)",
"name": "event_name",
"type": "string"
},
{
"default": null,
"doc": "Categorical classification based on their common purposes (CapitalCamelCase) (case sensitive)",
"name": "event_category",
"type": [
"null",
"string"
]
},
{
"doc": "When the event happens (Unix timestamp)",
"logicalType": "timestamp-millis",
"name": "event_ts",
"type": "long"
},
{
"doc": "When the event is sent from client to server (Unix timestamp)",
"logicalType": "timestamp-millis",
"name": "client_sent_ts",
"type": "long"
},
{
"doc": "When the event processing begins in API service (Unix timestamp)",
"logicalType": "timestamp-millis",
"name": "server_received_ts",
"type": "long"
},
{
"default": null,
"doc": "(Stringify) Custom data in JSON format",
"name": "event_data",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "Current page name (CapitalCamelCase) (case sensitive)",
"name": "page_name",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "Previous page name (CapitalCamelCase) (case sensitive)",
"name": "page_referer",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "A specific and identifiable element or part of a web page/application interface (CapitalCamelCase) (case sensitive)",
"name": "page_component",
"type": [
"null",
"string"
]
},
{
"default": 0,
"doc": "Screen width in pixel",
"name": "screen_width",
"type": "int"
},
{
"default": 0,
"doc": "Screen height in pixel",
"name": "screen_height",
"type": "int"
},
{
"doc": "HTTP domain",
"name": "http_domain",
"type": "string"
},
{
"default": null,
"doc": "Query string from URL",
"name": "http_search",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "HTTP referer",
"name": "http_referer",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "HTTP cookie",
"name": "http_cookie",
"type": [
"null",
"string"
]
},
{
"doc": "Path from URL (without domain name)",
"name": "url_path",
"type": "string"
},
{
"doc": "User agent from http request header",
"name": "user_agent",
"type": "string"
},
{
"default": null,
"doc": "IP address (from request header)",
"name": "ip",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "If the user is logged in, the user ID should be sent to the event. Refers to users._id in mongo.",
"name": "user_id",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "Language from client",
"name": "language",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "Time zone identifier from client. e.g. Asia/Taipei | Asia/Singapore | ...",
"name": "tz_identifier",
"type": [
"null",
"string"
]
},
{
"doc": "Merchant ID. Refers to merchants._id in mongo.",
"name": "merchant_id",
"type": "string"
},
{
"default": null,
"doc": "Session from client (follow the definition from client site)",
"name": "session_id",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "Channel ID. Refers to channels._id in mongo.",
"name": "channel_id",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "Browser version (from user_agent)",
"name": "browser_version",
"type": [
"null",
"string"
]
},
{
"default": null,
"doc": "True means mobile device (from user_agent)",
"name": "is_mobile",
"type": [
"null",
"boolean"
]
}
],
"name": "EventWebValue",
"namespace": "event",
"type": "record"
}Yuval Itzchakov
01/03/2024, 8:19 AMStan Hsu
01/03/2024, 8:20 AMThere are other messages raise the errorYuval Itzchakov
01/03/2024, 8:20 AMStan Hsu
01/03/2024, 8:21 AMYuval Itzchakov
01/03/2024, 12:05 PMStan Hsu
01/03/2024, 3:20 PM