Apache Drill: 从Json数据中选择时创建表错误

问题描述 投票:0回答:2

下面的命令工作得很好,但当我试图从select语句中创建一个表时,却出现了错误。

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]
json apache hadoop apache-drill mapr
2个回答
0
投票

你能不能试试在路径周围加上单引号,比如。

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;

0
投票

这是在工作

CREATE TABLE myHDFS.testdata.`xusersample2.json` AS SELECT * FROM myHDFS.testdata.`sample.json`。

带存储配置

"testdata"。{ "location", "dirdatatest", "writable": true, "defaultInputFormat": { "location": "dirdatatest", "writable": true, "defaultInputFormat": "json"}. "testdata": { "location": "dirdatatest", "writable": true, "defaultInputFormat": "json"},

© www.soinside.com 2019 - 2024. All rights reserved.