• hive字段关键字问题处理


            最近在xxl_job部署shell调度任务时,发现在编写Hql时,对一些使用关键字命名的字段无法解析,按开发规范,字段命名不应该有关键字,但是数据来源是第三方,无法修改,需要通过flume对从kafka的数据到hdfs上,数据是json格式,所以需要对关键字字段进行处理,最初是通过  `,',",‘,“  都无法识别,最后对通过转义字符解决了,解决方法如下:

    具体报错如下:

    1. 2023-10-23 11:42:52 [com.xxl.job.core.thread.JobThread#run]-[133]-[xxl-job, JobThread-14-1698032572739]
    2. ----------- xxl-job job execute start -----------
    3. ----------- Param:
    4. 2023-10-23 11:42:52 [com.xxl.job.core.handler.impl.ScriptJobHandler#execute]-[80]-[xxl-job, JobThread-14-1698032572739] ----------- script file:/data/applogs/xxl-job/jobhandler/gluesource/14_1698032568000.sh -----------
    5. xxl-job: hello shell
    6. SLF4J: Class path contains multiple SLF4J bindings.
    7. SLF4J: Found binding in [jar:file:/usr/hdp/3.1.4.0-315/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    8. SLF4J: Found binding in [jar:file:/usr/hdp/3.1.4.0-315/hadoop/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    9. SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    10. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
    11. Connecting to
    12. Connected to: Apache Hive (version 3.1.0.3.1.4.0-315)
    13. Driver: Hive JDBC (version 3.1.0.3.1.4.0-315)
    14. Transaction isolation: TRANSACTION_REPEATABLE_READ
    15. Error: Error while compiling statement: FAILED: ParseException line 4:70 cannot recognize input near 'local' ',' 'type' in select expression (state=42000,code=40000)
    16. Good bye!
    17. 2023-10-23 11:42:59 [com.xxl.job.core.thread.JobThread#run]-[179]-[xxl-job, JobThread-14-1698032572739]
    18. ----------- xxl-job job execute end(finish) -----------
    19. ----------- Result: handleCode=200, handleMsg = null
    20. 2023-10-23 11:42:59 [com.xxl.job.core.thread.TriggerCallbackThread#callbackLog]-[197]-[xxl-job, executor TriggerCallbackThread]
    21. ----------- xxl-job job callback finish.
    22. 2023-10-23 11:43:35 [com.xxl.job.core.thread.JobThread#run]-[194]-[xxl-job, JobThread-14-1698032572739]
    23. ----------- JobThread toStop, stopReason:change job source or glue type, and terminate the old job thread.
    24. 2023-10-23 11:43:35 [com.xxl.job.core.thread.JobThread#run]-[204]-[xxl-job, JobThread-14-1698032572739]
    25. ----------- JobThread Exception:java.lang.InterruptedException
    26. at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014)
    27. at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2088)
    28. at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
    29. at com.xxl.job.core.thread.JobThread.run(JobThread.java:114)
    30. ----------- xxl-job job execute end(error) -----------

    比如需要对local,type关键字进行转义,转义规则如下:

    \`local\`,\`type\`

    问题解决。

  • 相关阅读:
    mySQL相关操作(不看是你的损失)
    计算机毕业设计(附源码)python职称评审系统设计
    代理模式和静态代理
    如何在Qt中使用boost库
    云IDE测试案例
    Python修改证件照底色,get新技能
    WebSocket集群解决方案,不用MQ
    jQuery过滤器:筛选jquery对象数组中的DOM对象
    【工程总结】Apollo-Cyber RT 中间件总结1
    Vue2电商前台项目——完成加入购物车功能和购物车页面
  • 原文地址:https://blog.csdn.net/jiedaodezhuti/article/details/133992275