seatunnel icon indicating copy to clipboard operation
seatunnel copied to clipboard

[Feature][Connector Hive] support hive savemode

Open liunaijie opened this issue 9 months ago • 25 comments

Purpose of this pull request

subtask of #5390

  1. implement hive savemode feature,
  2. add chinese document

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

  • [ ] If any new Jar binary package adding in your PR, please add License Notice according New License Guide
  • [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
  • [ ] If you are contributing the connector code, please check that the following files are updated:
    1. Update change log that in connector document. For more details you can refer to connector-v2
    2. Update plugin-mapping.properties and add new connector information in it
    3. Update the pom file of seatunnel-dist
  • [ ] Update the release-note.

liunaijie avatar May 11 '24 09:05 liunaijie

@EricJoy2048 @dailai @ruanwenjun hi, guys. PTAL when you have time.

liunaijie avatar May 16 '24 10:05 liunaijie

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '<EOF>' '<EOF>' '<EOF>'

NoPr avatar May 22 '24 02:05 NoPr

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

liunaijie avatar May 22 '24 06:05 liunaijie

partition image

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

是的,当schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST"时,save_mode_create_template 是必须的吗?当为 “” 时,报错为我描述的那个错误

NoPr avatar May 22 '24 07:05 NoPr

partition image

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

是的,当schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST"时,save_mode_create_template 是必须的吗?当为 “” 时,报错为我描述的那个错误

是必须的, 这个是你表不存在时的要执行的建表语句

liunaijie avatar May 22 '24 07:05 liunaijie

partition image

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

是的,当schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST"时,save_mode_create_template 是必须的吗?当为 “” 时,报错为我描述的那个错误

是必须的, 这个是你表不存在时的要执行的建表语句

那如果我不知道source的表结构的话,是否该source-sink的conf就不能成立?这个和mysql的schema_save_mode 的配置实现的效果不一样吗?

NoPr avatar May 22 '24 08:05 NoPr

partition image

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

是的,当schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST"时,save_mode_create_template 是必须的吗?当为 “” 时,报错为我描述的那个错误

是必须的, 这个是你表不存在时的要执行的建表语句

那如果我不知道source的表结构的话,是否该source-sink的conf就不能成立?这个和mysql的schema_save_mode 的配置实现的效果不一样吗?

有些许的不一样 可以拿到source的表结构, 然后根据这个结构去创建表 但是其他的Hive配置, 比如内表/外表, 外表路径, 存储格式等等的配置是无法拿到的. 所以添加了这个参数 希望用户自定义DDL语句

liunaijie avatar May 22 '24 08:05 liunaijie

partition image

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

是的,当schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST"时,save_mode_create_template 是必须的吗?当为 “” 时,报错为我描述的那个错误

是必须的, 这个是你表不存在时的要执行的建表语句

那如果我不知道source的表结构的话,是否该source-sink的conf就不能成立?这个和mysql的schema_save_mode 的配置实现的效果不一样吗?

有些许的不一样 可以拿到source的表结构, 然后根据这个结构去创建表 但是其他的Hive配置, 比如内表/外表, 外表路径, 存储格式等等的配置是无法拿到的. 所以添加了这个参数 希望用户自定义DDL语句

那也就是说hive的自定义建表需要满足: 1.已知source表结构 2.自定义建表语句并作为sink的参数

NoPr avatar May 22 '24 08:05 NoPr

image 老哥稳,我试过了。 image

NoPr avatar May 23 '24 06:05 NoPr

image 老哥稳,我试过了。 image

目前的代码还有几个问题:

  1. 你上面的语句 没有指定分隔符, 如果指定了类似于 \t 这样的分割符, 写入Config后会变成 \\t, 导致文件写入有问题.
  2. 由于查询hive表结构是通过desc formatted <table_name>的方式 然后解析sql结果. 目前发现在不同的版本中 返回语句会略有不同, 3.1.3 版本 在 # col_name与真正的字段名直接没有空行, 而在2.1.1版本中 发现会多一个空行. 目前的代码这块的处理逻辑需要兼容 以及优化.
  3. 不确定开启kerberos认证后 是否可以连通, 我这边是使用用户名密码, 可以通过在jdbc url中设置完成这个认证.

liunaijie avatar May 23 '24 07:05 liunaijie

Modify the hive documentation by referring to mysql.md @liunaijie
https://github.com/apache/seatunnel/blob/dev/docs/en/connector-v2/sink/Mysql.md https://github.com/apache/seatunnel/blob/dev/docs/en/connector-v2/source/Mysql.md

zhilinli123 avatar May 24 '24 08:05 zhilinli123

image 老哥稳,我试过了。 image

目前的代码还有几个问题:

  1. 你上面的语句 没有指定分隔符, 如果指定了类似于 \t 这样的分割符, 写入Config后会变成 \\t, 导致文件写入有问题.
  2. 由于查询hive表结构是通过desc formatted <table_name>的方式 然后解析sql结果. 目前发现在不同的版本中 返回语句会略有不同, 3.1.3 版本 在 # col_name与真正的字段名直接没有空行, 而在2.1.1版本中 发现会多一个空行. 目前的代码这块的处理逻辑需要兼容 以及优化.
  3. 不确定开启kerberos认证后 是否可以连通, 我这边是使用用户名密码, 可以通过在jdbc url中设置完成这个认证.

problem 1, 2 solved problem 3, i don't have this env, can't verify about this.

liunaijie avatar Jun 03 '24 09:06 liunaijie

partition image

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

大佬你好,创建的statement好像有点问题 org.apache.hadoop.hive.ql.parse.ParseException:line 1:0 cannot recognize input near '' '' ''

是提交partition信息的语句吗 还是哪个语句?

是的,当schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST"时,save_mode_create_template 是必须的吗?当为 “” 时,报错为我描述的那个错误

是必须的, 这个是你表不存在时的要执行的建表语句

那如果我不知道source的表结构的话,是否该source-sink的conf就不能成立?这个和mysql的schema_save_mode 的配置实现的效果不一样吗?

代码更新了一版, 可以在不知道上游表结构的情况下, 使用变量的形式 运行时替换掉. 有一点需要注意的是 如果存在分区, 则需要添加额外的参数标明分区字段, 并且分区字段不能变量化, 即多张上游表只能用一个模板内的分区定义, 不能针对每个表建不同的分区.

liunaijie avatar Jun 07 '24 03:06 liunaijie

waitting for this pr merged #7131

ok, will update when the pr merged

liunaijie avatar Jul 19 '24 09:07 liunaijie

waitting for this pr merged #7131

@liunaijie this pr is merged

hailin0 avatar Jul 22 '24 14:07 hailin0

@liunaijie Please resolve the conflict, thanks

wuchunfu avatar Aug 15 '24 04:08 wuchunfu

加油啊

NoPr avatar Aug 19 '24 03:08 NoPr

你好,我想问下,这个e2e是怎么跑起来的,我的为什么一直都跑不起来呢? image

lilanlong avatar Aug 21 '24 08:08 lilanlong

你好,我想问下,这个e2e是怎么跑起来的,我的为什么一直都跑不起来呢? image

你好,我想问下,这个e2e是怎么跑起来的,我的为什么一直都跑不起来呢? image

Share how to run e2e on my desktop:

  1. compile/install the project
  2. start docker env
  3. choose the Test, like FakeIT, click run

liunaijie avatar Aug 21 '24 09:08 liunaijie

你好,我想问下,这个e2e是怎么跑起来的,我的为什么一直都跑不起来呢? image

你好,我想问下,这个e2e是怎么跑起来的,我的为什么一直都跑不起来呢? image

Share how to run e2e on my desktop:

  1. compile/install the project
  2. start docker env
  3. choose the Test, like FakeIT, click run

我也是这样操作的,但是还是不行,对docker的版本有要求吗? image

lilanlong avatar Aug 22 '24 02:08 lilanlong

你好,我想问下,这个e2e是怎么跑起来的,我的为什么一直都跑不起来呢? image

你好,我想问下,这个e2e是怎么跑起来的,我的为什么一直都跑不起来呢? image

Share how to run e2e on my desktop:

  1. compile/install the project
  2. start docker env
  3. choose the Test, like FakeIT, click run

我也是这样操作的,但是还是不行,对docker的版本有要求吗? image

No requirement for Docker version.

From the error message Could not find or load main class, looks the package has some issue. You can run install command, and copy the final lib, try to run with this lib directly.

liunaijie avatar Aug 22 '24 09:08 liunaijie

@liunaijie Does sink support writing to specified partitions?

wuchunfu avatar Aug 29 '24 05:08 wuchunfu

@liunaijie Can you provide some examples of source and sink JDBC or e2e?

wuchunfu avatar Aug 29 '24 05:08 wuchunfu

@liunaijie Does sink support writing to specified partitions?

Hi @wuchunfu this pr only add hive savemode function. you mentioned write to specified partition it's implement in the hive writer.

base on my understanging, it's dependency on the upstream data. if the partition column value in upstream is limited, then it will only write to those partition.

the demo config file is https://github.com/apache/seatunnel/pull/6842/files#diff-d7baf931b751ae313c92a9e96e2537e61726e2add691adad696251cb5dec926fR48

I tested it in my local desktop with example module, but the e2e is not enable, because it need hive metastore and hive server2 2 container, i try to enable it in e2e but failed... so i only attach the example config

liunaijie avatar Aug 30 '24 03:08 liunaijie

I tested it in my local desktop with example module, but the e2e is not enable, because it need hive metastore and hive server2 2 container, i try to enable it in e2e but failed... so i only attach the example config

Have you try with https://hub.docker.com/r/apache/hive?

Hisoka-X avatar Sep 02 '24 03:09 Hisoka-X