[关闭]
@bdap 2017-12-28T01:50:20.000000Z 字数 4376 阅读 11085

常见报错

D-query


Presto常见报错

非全表权限时需查询v_presto_开头的视图表

报错SQL:

select
  ds as "日期",
  sum(login_cnt) as "登录人数"
from
  data_analyze_topresto.dm_gamelog_account_ds
where
  gameid = 94
  and cast(group_type as integer)= 99
  and cast(player_type as integer) = 99
  and ds between '20170326'
  and '20170427'
group by
  ds

报错信息:

Error: can not access to the table:data_analyze_topresto.dm_gamelog_account_ds(没有权限访问表:data_analyze_topresto.dm_gamelog_account_ds)

报错原因:data_analyze_topresto.dm_gamelog_account_ds表中包含所有游戏数据,用户只有部分游戏数据权限,无法查询该表,需要查询v_presto_开头的视图表(data_analyze_topresto.v_presto_dm_gamelog_account_ds)

正确SQL:

select
  ds as "日期",
  sum(login_cnt) as "登录人数"
from
  data_analyze_topresto.v_presto_dm_gamelog_account_ds
where
  gameid = 94
  and cast(group_type as integer)= 99
  and cast(player_type as integer) = 99
  and ds between '20170326'
  and '20170427'
group by
  ds

Presto查询数据表需写明所在数据库

报错SQL:

select
  ds as "日期",
  sum(login_cnt) as "登录人数"
from
  dm_gamelog_account_ds
where
  gameid = 94
  and cast(group_type as integer)= 99
  and cast(player_type as integer) = 99
  and ds between '20170326'
  and '20170427'
group by ds
order by ds

报错信息:

Error: SQLException:java.sql.SQLException: Query failed (#20170725_063945_00191_89qic): line 5:2: Schema must be specified when session schema is not set

报错原因:需要写明数据表所在数据库

正确SQL:

select
  ds as "日期",
  sum(login_cnt) as "登录人数"
from
  data_analyze_topresto.dm_gamelog_account_ds
where
  gameid = 94
  and cast(group_type as integer)= 99
  and cast(player_type as integer) = 99
  and ds between '20170326'
  and '20170427'
group by
  ds

Presto中的中文

报错SQL:

select
  ds as 日期,
  sum(login_cnt) as 登录人数
from
  data_analyze_topresto.dm_gamelog_account_ds
where
  gameid = 94
  and cast(group_type as integer)= 99
  and cast(player_type as integer) = 99
  and ds between '20170326'
  and '20170427'
group by ds
order by ds

报错信息:

Error: line 2:9 no viable alternative at input '日'(错误的sql)

报错原因:中文格式不对,需使用"中文"格式

正确SQL:

select
  ds as "日期",
  sum(login_cnt) as "登录人数"
from
  data_analyze_topresto.dm_gamelog_account_ds
where
  gameid = 94
  and cast(group_type as integer)= 99
  and cast(player_type as integer) = 99
  and ds between '20170326'
  and '20170427'
group by
  ds

字段格式问题

示例SQL:

select
  ds as "日期",
  sum(login_cnt) as "登录人数"
from
  data_analyze_topresto.dm_gamelog_account_ds
where
  gameid = 94
  and group_type = 99
  and player_type = 99
  and ds between '20170326'
  and '20170427'
group by
  ds

报错信息:

Error: SQLException:java.sql.SQLException: Query failed (#20170725_062545_00187_89qic): line 8:17: '=' cannot be applied to varchar, integer

报错原因:group_type和player_type都是varchar类型,99是整数类型,“=”号双方格式不一致,需进行格式转换。

正确SQL:

select
  ds as "日期",
  sum(login_cnt) as "登录人数"
from
  data_analyze_topresto.dm_gamelog_account_ds
where
  gameid = 94
  and cast(group_type as integer)= 99
  and cast(player_type as integer) = 99
  and ds between '20170326'
  and '20170427'
group by
  ds

数字开头的数据表

示例SQL:

SELECT
  *
from
  ba_log.152_pay_log
limit
  10

报错信息:

Error: line 4:7 extraneous input '.152' expecting {, ',', '.', 'ADD', 'AS', 'ALL', 'SOME', 'ANY', 'WHERE', 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'AT', 'NO', 'SUBSTRING', 'POSITION', 'TINYINT', 'SMALLINT', 'INTEGER', 'DATE', 'TIME', 'TIMESTAMP', 'INTERVAL', 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND', 'ZONE', 'JOIN', 'CROSS', 'INNER', 'LEFT', 'RIGHT', 'FULL', 'NATURAL', 'FILTER', 'OVER', 'PARTITION', 'RANGE', 'ROWS', 'PRECEDING', 'FOLLOWING', 'CURRENT', 'ROW', 'SCHEMA', 'COMMENT', 'VIEW', 'REPLACE', 'GRANT', 'REVOKE', 'PRIVILEGES', 'PUBLIC', 'OPTION', 'GRANTS', 'EXPLAIN', 'ANALYZE', 'FORMAT', 'TYPE', 'TEXT', 'GRAPHVIZ', 'LOGICAL', 'DISTRIBUTED', 'VALIDATE', 'SHOW', 'TABLES', 'SCHEMAS', 'CATALOGS', 'COLUMNS', 'COLUMN', 'USE', 'PARTITIONS', 'FUNCTIONS', 'UNION', 'EXCEPT', 'INTERSECT', 'TO', 'SYSTEM', 'BERNOULLI', 'POISSONIZED', 'TABLESAMPLE', 'ARRAY', 'MAP', 'SET', 'RESET', 'SESSION', 'DATA', 'START', 'TRANSACTION', 'COMMIT', 'ROLLBACK', 'WORK', 'ISOLATION', 'LEVEL', 'SERIALIZABLE', 'REPEATABLE', 'COMMITTED', 'UNCOMMITTED', 'READ', 'WRITE', 'ONLY', 'CALL', 'INPUT', 'OUTPUT', 'CASCADE', 'RESTRICT', 'INCLUDING', 'EXCLUDING', 'PROPERTIES', 'NFD', 'NFC', 'NFKD', 'NFKC', 'IF', 'NULLIF', 'COALESCE', IDENTIFIER, DIGIT_IDENTIFIER, QUOTED_IDENTIFIER, BACKQUOTED_IDENTIFIER}(错误的sql)

报错原因:数字开头的数据表需要用双引号标识

正确SQL:

SELECT
  *
from
  ba_log."152_pay_log"
limit
  10

D-Query版本说明

V1.0

发布时间:2017-08-01
版本说明:
D-Query基本功能部署上线:
1、SQL查询页、查询历史页、保存的查询页功能完成并上线
2、支持Presto和Hive查询
3、支持数据下载和预览等功能
4、接入统一登录系统
5、完成国际化开发

V1.0.1

发布时间:2017-08-15
版本说明:
1、支持查询选中SQL
2、通配符功能上线,支持参数化查询
3、接入授权系统,增加登录验证

V1.1

发布时间:2017-10-24
版本说明:
D-Query二期功能上线:
1、定时任务功能上线,支持设置定时任务并邮件发送查询结果
2、用户组方案调整,接入员工信息中枢系统架构数据
3、参数化功能优化,打通Dquery和Dcube参数结构
4、增加页面埋点

V1.2

发布时间:2017-11-24
版本说明:
自定义数据表功能上线
1、支持新建临时表
2、可以在已有临时表中插入数据
3、支持将存储结果存储为新表

V1.3

发布时间:2018-01-09
版本说明:
1、增加XLS格式下载
2、定时任务队列修改,并行任务修改为多个类型的执行队列, hive可以同时查6个 presto可以同时查3个
3、定时任务开始跑数时间前移到7点
4、支持将在私有库中新建数据表或添加数据

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注