Hi Team, When I am trying to implement the FlinkPi...
# flink-cdc
h
Hi Team, When I am trying to implement the FlinkPipeline with Postgres -> S3Tables I am keep getting follwoing error. Please can someone suggest what could be the issue
Copy code
java.lang.IllegalArgumentException: Cannot initialize Catalog, software.amazon.s3tables.iceberg.S3TablesCatalog does not implement Catalog.
	at org.apache.iceberg.CatalogUtil.loadCatalog(CatalogUtil.java:251)
	at org.apache.iceberg.CatalogUtil.buildIcebergCatalog(CatalogUtil.java:310)
	at org.apache.flink.cdc.connectors.iceberg.sink.v2.IcebergCommitter.<init>(IcebergCommitter.java:72)
	at org.apache.flink.cdc.connectors.iceberg.sink.v2.IcebergSink.createCommitter(IcebergSink.java:85)
	at org.apache.flink.streaming.runtime.operators.sink.CommitterOperatorFactory.lambda$createStreamOperator$0(CommitterOperatorFactory.java:65)
	at org.apache.flink.streaming.runtime.operators.sink.CommitterOperator.initializeState(CommitterOperator.java:124)
	at org.apache.flink.streaming.api.operators.StreamOperatorStateHandler.initializeOperatorState(StreamOperatorStateHandler.java:147)
	at org.apache.flink.streaming.api.operators.AbstractStreamOperator.initializeState(AbstractStreamOperator.java:294)
	at org.apache.flink.streaming.runtime.tasks.RegularOperatorChain.initializeStateAndOpenOperators(RegularOperatorChain.java:106)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreStateAndGates(StreamTask.java:858)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.lambda$restoreInternal$5(StreamTask.java:812)
	at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreInternal(StreamTask.java:812)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:771)
	at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:970)
	at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:939)
	at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:763)
	at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.ClassCastException: class software.amazon.s3tables.iceberg.S3TablesCatalog cannot be cast to class org.apache.iceberg.catalog.Catalog (software.amazon.s3tables.iceberg.S3TablesCatalog is in unnamed module of loader 'app'; org.apache.iceberg.catalog.Catalog is in unnamed module of loader org.apache.flink.util.ChildFirstClassLoader @57574296)
	at org.apache.iceberg.CatalogUtil.loadCatalog(CatalogUtil.java:247)
	... 18 more
My Pipeline look like
Copy code
source:
  type: postgres
  hostname: localhost
  port: 5432
  username: postgres
  password: postgres
  tables: postgres.public.\.*
  slot.name: flink_cdc_slot   # replication slot name (auto-created if absent)
  scan.startup.mode: initial  # snapshot then stream


sink:
  type: iceberg
  name: Iceberg Sink
  catalog.properties.region: us-west-2
  catalog.properties.warehouse: arn:aws:s3tables:us-west-2:774331681746:bucket/flink-example
  catalog.properties.catalog-impl: software.amazon.s3tables.iceberg.S3TablesCatalog
  

pipeline:
  name: PG ➜ S3Table (local)
  parallelism: 2
s
Did you get this to work ?
h
no
I am able to make it working with Glue catalog but with S3 Table not working
s
Yes I am struggling with documentation as well not much resource
a
you have to pass hoodi config
Copy code
s3.fs.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
s3.endpoint: "s3.amazonaws.com"
fs.s3.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
fs.s3a.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
am working on a poc, so far have gotten mysql working , struggling with postgres, will share my progress once I have postgres working
s
Is this s3 tables
a
yes, I am able to push mysql/postgres data into iceberg, my current setup is bit of a mess. but is working
Copy code
---
apiVersion: flink.apache.org/v1beta1
kind: FlinkDeployment
metadata:
  name: ${DEPLOYMENT_NAME}
  namespace: ${NAMESPACE}
spec:
  flinkConfiguration:
    classloader.resolve-order: parent-first
    execution.checkpointing.interval: ${CHECKPOINT_INTERVAL}
    execution.checkpointing.min-pause: ${CHECKPOINT_MIN_PAUSE}
    execution.checkpointing.savepoint-dir: ${SAVEPOINT_DIR}
    execution.checkpointing.dir: ${CHECKPOINT_DIR}
    fs.s3.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
    s3.fs.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
    fs.s3a.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
    fs.s3a.access.key: ${S3_ACCESS_KEY}
    fs.s3a.secret.key: ${S3_SECRET_KEY}
    fs.s3a.endpoint: s3.amazonaws.com
    fs.s3a.path.style.access: 'false'
    fs.s3a.aws.credentials.provider: org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider
    fs.s3a.region: us-east-1
    heartbeat.timeout: 60000
    log4j.logger.org.apache.flink.cdc.common.data.binary.BinaryRecordData: DEBUG
    log4j.logger.org.apache.flink.cdc.connectors.postgres.source.PostgresEventDeserializer: DEBUG
    log4j.logger.org.apache.flink.cdc.connectors.iceberg.sink.utils.IcebergTypeUtils: DEBUG
  flinkVersion: v1_20
  image: ${FLINK_IMAGE}
  imagePullPolicy: Always
  job:
    args:
      - '--use-mini-cluster'
      - /opt/flink/flink-cdc-3.5.0/conf/${PIPELINE_FILE_NAME}
    entryClass: org.apache.flink.cdc.cli.CliFrontend
    jarURI: 'local:///opt/flink/lib/flink-cdc-dist-3.5.0.jar'
    parallelism: 1
    state: running
    upgradeMode: savepoint
  jobManager:
    replicas: 1
    resource:
      cpu: 2
      memory: 8192m
  podTemplate:
    apiVersion: v1
    kind: Pod
    spec:
      containers:
        # don't modify this name
        - name: flink-main-container
          volumeMounts:
            - mountPath: /opt/flink/flink-cdc-3.5.0/conf
              name: flink-cdc-pipeline-config
            - mountPath: /opt/flink/hadoop-conf
              name: hadoop-conf
          env:
            - name: HADOOP_CONF_DIR
              value: /opt/flink/hadoop-conf
      volumes:
        - configMap:
            name: ${CONFIG_MAP_NAME}
          name: flink-cdc-pipeline-config
        - configMap:
            name: ${CONFIG_MAP_NAME}
            items:
              - key: core-site.xml
                path: core-site.xml
          name: hadoop-conf
  restartNonce: 0
  serviceAccount: flink
  taskManager:
    resource:
      cpu: 2
      memory: 8192m
core-site.xml
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>fs.s3.impl</name>
        <value>org.apache.hadoop.fs.s3a.S3AFileSystem</value>
    </property>
    <property>
        <name>fs.s3a.impl</name>
        <value>org.apache.hadoop.fs.s3a.S3AFileSystem</value>
    </property>
    <property>
        <name>fs.s3a.access.key</name>
        <value>${S3_ACCESS_KEY}</value>
    </property>
    <property>
        <name>fs.s3a.secret.key</name>
        <value>${S3_SECRET_KEY}</value>
    </property>
    <property>
        <name>fs.s3a.endpoint</name>
        <value>s3.amazonaws.com</value>
    </property>
    <property>
        <name>fs.s3a.path.style.access</name>
        <value>false</value>
    </property>
    <property>
        <name>fs.s3a.aws.credentials.provider</name>
        <value>org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider</value>
    </property>
    <property>
        <name>fs.s3a.region</name>
        <value>us-east-1</value>
    </property>
</configuration>
myqsl_to_iceberg_conf.yaml
Copy code
---
source:
  type: "mysql"
  hostname: ${MYSQL_HOST}
  port: ${MYSQL_PORT}
  username: ${MYSQL_USERNAME}
  password: ${MYSQL_PASSWORD}
  tables: ${MYSQL_TABLES}
  server-id: ${MYSQL_SERVER_ID}
  server-time-zone: ${MYSQL_SERVER_TIMEZONE}

sink:
  type: "iceberg"
  name: "Iceberg Sink"
  catalog.properties.type: ${ICEBERG_CATALOG_TYPE}
  catalog.properties.uri: ${ICEBERG_CATALOG_URI}
  catalog.properties.warehouse: ${ICEBERG_CATALOG_WAREHOUSE}

pipeline:
  name: "Sync MySQL Database to Iceberg"
  parallelism: "2"
pg_to_iceberg.yaml
Copy code
---
source:
  type: "postgres"
  name: ${POSTGRES_SOURCE_NAME}
  hostname: ${POSTGRES_HOST}
  port: ${POSTGRES_PORT}
  username: ${POSTGRES_USERNAME}
  password: ${POSTGRES_PASSWORD}
  tables: ${POSTGRES_TABLES}
  slot.name: ${POSTGRES_SLOT_NAME}
  jdbc.properties.useSSL: ${POSTGRES_JDBC_USESSL}

sink:
  type: "iceberg"
  name: "Iceberg Sink"
  catalog.properties.type: ${ICEBERG_CATALOG_TYPE}
  catalog.properties.uri: ${ICEBERG_CATALOG_URI}
  catalog.properties.warehouse: ${ICEBERG_CATALOG_WAREHOUSE}

pipeline:
  name: "Sync Postgres Database to Iceberg"
  parallelism: "2"
flink_conf.yaml
Copy code
parallelism: 4
schema.change.behavior: EVOLVE
execution.checkpointing.interval: 60s
execution.checkpointing.min-pause: 30s
s3.access-key: ${S3_ACCESS_KEY}
s3.secret-key: ${S3_SECRET_KEY}
s3.fs.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
s3.endpoint: "s3.amazonaws.com"
fs.s3.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
fs.s3a.impl: "org.apache.hadoop.fs.s3a.S3AFileSystem"
fs.s3a.access.key: ${S3_ACCESS_KEY}
fs.s3a.secret.key: ${S3_SECRET_KEY}
fs.s3a.endpoint: "s3.amazonaws.com"
fs.s3a.region: "us-east-1"
fs.s3a.aws.credentials.provider: "org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider"
fs.s3a.path.style.access: "false"
h
@A S Rakesh Krishna is this S3 Table or Iceberg ?
a
for pushing from mysql/postgres to s3 buckets in iceberg format
h
Problem I am facing with S3 TAble
Which Is Managed instance for Icebeg by AWS
a
oh, I did not know about S3 Tables. I am just pushing to s3 buckets