Hadoop集群升级带来的ORC文件问题与Python脚本推送Hive到StarRocks

1、问题分析

      在Hadoop集群升级后,用户可能会注意到生成的ORC文件中的列名不再是抽象的"_col0"、"_col1"等,而是实际的列名。这一变化是ORC文件格式的新版本引入的。这对于数据理解和查询来说是一大进步,但可能会导致一些问题,比如我们可能会遇到类似以下的错误消息:

  • msg:OrcMappingFactory::_init_orc_mapping not found column name _col2
升级后生成的ORC文件列名不再是_col0,_col1等,而是实际的列名
  • No source file in this table(table_name)

升级后 union的表没有了子目录,hdfs文件只有一层目录

2、 Python脚本推送hive数据到starrocks 

load_cmd = '''    
    {truncate_data}
    LOAD LABEL {label}
    (
    DATA INFILE('{file}')
    INTO TABLE {table}
    {tmp_pname}
    {col_terminated}
    {format}
    {column_mapping}
    )
    WITH BROKER 'broker1'
    (
        'username' = 'root',
        'password' = 'pwd'
    )
    PROPERTIES
    (
        'timeout'          = '3600',
        'max_filter_ratio' = '0.01'
    );
'''.format(truncate_data=truncate_sql, label=star_database + '_' + star_table + '_' + timestamp, file=file_path,
               table=star_table, tmp_pname=star_temp_partition_path, format=hive_file_format,
               col_terminated=hive_columns_terminated, column_mapping=col_map)

 以上代码中需要上述报错的地方分别是 file_path,column_mapping的赋值

hdfs://mycluster/user/hive/warehouse/fdp/ads.db/ads_**_board_da/dt=20231015/*/*    (替换为)->  hdfs://mycluster/user/hive/warehouse/fdp/ads.db/ads_**_board_da/dt=20231015/*

   因为列名的改变,column_mapping就不用自己指定匹配了,默认的就行,因此

column_mapping=col_map  (替换为)->   column_mapping=''
posted @ 2023-10-16 17:53  LUDAGOGO  阅读(187)  评论(0)    收藏  举报