apache drill:从json数据选择时发生create table错误

lmyy7pcs  于 2021-05-29  发布在  Hadoop
关注(0)|答案(2)|浏览(365)

下面的命令运行良好。

SELECT TO_TIMESTAMP(`ts`,'yyyyMMddHHmmss') 
FROM dfs.tmp`/mapr/my.cluster.com/hive/cpf_sales.json

但是当我试图从select语句创建一个表时,它给出了一个错误。下面是我试过的

ALTER SESSION SET `store.format`='json';
use dfs;

CREATE TABLE by_yr (gen_date)  AS SELECT TO_TIMESTAMP(`ts`,'yyyyMMddHHmmss') FROM dfs.`/mapr/my.cluster.com/hive/cpf_sales.json` LIMIT 100;

**Error:**

org.apache.drill.common.exceptions.UserRemoteException: PARSE ERROR: Encountered ";" at line 1, column 8. Was expecting one of: "." ... "[" ... SQL Query use dfs; ^ CREATE TABLE by_yr (gen_date) AS SELECT TO_TIMESTAMP(`ts`,'yyyyMMddHHmmss') FROM dfs.`/mapr/my.cluster.com/hive/cpf_sales.json` LIMIT 100 [Error Id: 81cbe394-b3c6-4c34-80ad-83325f748ae1 on iot3:31010]

use dfs.tmp;

CREATE TABLE by_yr (gen_date)  AS SELECT TO_TIMESTAMP(`ts`,'yyyyMMddHHmmss') FROM dfs.tmp`/mapr/my.cluster.com/hive/cpf_sales.json` LIMIT 100;

**Error:**

org.apache.drill.common.exceptions.UserRemoteException: PARSE ERROR: Encountered ";" at line 1, column 12. Was expecting one of: "." ... "[" ... SQL Query use dfs.tmp; ^ SELECT COLUMNS[0], COLUMNS[1] from dfs.tmp.`/mapr/my.cluster.com/donuts.json` [Error Id: 5e9d1d20-a804-4d09-8b69-d76b3c009647 on iot2:31010]
ep6jt1vc

ep6jt1vc1#

你能试着在路径周围加上单引号吗,比如:

ALTER SESSION SET store.format='json'; use dfs;

CREATE TABLE by_yr (gen_date) AS 
SELECT TO_TIMESTAMP(ts,'yyyyMMddHHmmss') 
FROM dfs.'/mapr/my.cluster.com/hive/cpf_sales.json' LIMIT 100;
i7uq4tfw

i7uq4tfw2#

这是有效的
创建表myhdfs.testdata./xuser/sample2.jsonas select*from myhdfs.testdata.sample.json
具有存储配置
“testdata”:{“location”:“/dir/data/test”,“writable”:true,“defaultinputformat”:“json”},

相关问题