[Hasor framework] DataQL aggregation query engine SQL executor reports error Query dialect missing cause analysis and solution (for GreenPlum database)

This article has participated in the "Newcomer Creation Ceremony" event to start the road of gold creation together.

1. Error description

Two platforms are built locally. The versions of hasor core dependencies are the same. Both GreenPlum databases are connected , and the same DataQL statements are executed:

        <!--hasor核心依赖【是老平台接入,由于兼容问题,最终用的并不是最新的4.2.5版本】-->
        <dependency>
            <groupId>net.hasor</groupId>
            <artifactId>hasor-spring</artifactId>
            <version>4.2.1</version>
        </dependency>
        <dependency>
            <groupId>net.hasor</groupId>
            <artifactId>hasor-dataway</artifactId>
            <version>4.2.1</version>
        </dependency>
复制代码

Here is the DataQL executed:

// SQL 执行器切换为分页模式及首页页面设置
hint FRAGMENT_SQL_QUERY_BY_PAGE = true
hint FRAGMENT_SQL_QUERY_BY_PAGE_NUMBER_OFFSET = 1

// 定义查询SQL
var query = @@sql() <%
    select * from yz_test_match
%>
 
// 创建分页查询对象
var pageQuery =  query(${pageSize},${pageNumber});
 
// 设置分页信息
run pageQuery.setPageInfo({
    "pageSize"    : #{pageSize}, 
    "currentPage" : #{pageNumber}
});
 
// 执行分页查询
var result = pageQuery.data();

// 查询分页信息
//var result = pageQuery.pageInfo();
return result;
复制代码

Why are there two platforms, the difference is the configuration file:

# 报错配置【使用的是GreenplumDriver】【这个是要集成项目的配置信息】
spring:
  application:
    name: dataWay-demo
  datasource:
    url: jdbc:pivotal:greenplum://xxx.xx.xxx.xxx:2345;DatabaseName=gpdb
    username: gpadmin
    password: gpadmin
    driver-class-name: com.pivotal.jdbc.GreenplumDriver
    type: com.alibaba.druid.pool.DruidDataSource
        
# 未报错配置【使用的是P6SpyDriver和postgresql的组合】
spring:
  application:
    name: dataWay-demo
  datasource:
    url: jdbc:p6spy:postgresql://xxx.xx.xxx.xxx:2345/gpdb
    username: gpadmin
    password: gpadmin
    driver-class-name: com.p6spy.engine.spy.P6SpyDriver
    type: com.alibaba.druid.pool.DruidDataSource
复制代码

Error message [some unnecessary information is omitted]:

2021-07-23 15:15:26.877 ERROR 9904 --- [nio-8088-exec-1] n.hasor.dataway.service.ApiCallService   : [line 9:17~11:2 ,QIL 1:6] Query dialect missing.
net.hasor.dataql.runtime.InstructRuntimeException: [line 9:17~11:2 ,QIL 1:6] Query dialect missing.
Caused by: java.lang.IllegalArgumentException: Query dialect missing.
复制代码

2. Cause analysis

Since it is an old project integrating Hasor, the project uses greenplum driver. The official website describes the dialect used by the executor as follows [after version 4.2.1, the SQL executor will automatically infer the corresponding dialect according to the database connection used], and Hasor The greenplum database dialect is not supported, but PostgreSQL is supported. [gp database is evolved from pg data], so consider using FRAGMENT_SQL_PAGE_DIALECT to configure it:Please add image description

3. Problem solving

According to the description of the official website, DataQL has added a statement to set the dialect:

hint FRAGMENT_SQL_PAGE_DIALECT = postgresql
复制代码

Error:

{
  "success": false,
  "message": "line 2:33 mismatched input 'postgresql' expecting {'true', 'false', 'null', STRING, HEX_NUM, OCT_NUM, BIT_NUM, INTEGER_NUM, DECIMAL_NUM}",
  "code": 500,
  "lifeCycleTime": 5,
  "executionTime": -1,
  "value": "line 2:33 mismatched input 'postgresql' expecting {'true', 'false', 'null', STRING, HEX_NUM, OCT_NUM, BIT_NUM, INTEGER_NUM, DECIMAL_NUM}"
}
复制代码

I laughed when I saw it [modified and tested again]:

hint FRAGMENT_SQL_PAGE_DIALECT = "postgresql"
复制代码

success:

{
  "success": true,
  "message": "OK",
  "code": 0,
  "lifeCycleTime": 17,
  "executionTime": 11,
  "value": {
    "firstrecommendfield": "豫K9F573",
    "secondrecommendfield": "460010993506966",
    "isusing": 1,
    "futurestartdate": 1618934400000,
    "handle": 1,
    "possibility": 1,
    "attribution": null,
    "sourcetype": 0
  }
}
复制代码

4. Make a summary

The official website is the best information to solve the problem, but many official website's description documents are almost meaningless. In the end, it is necessary to analyze the problem and look at the error message. If the error message is unclear, it is necessary to analyze the source code.

Guess you like

Origin juejin.im/post/7085354255942418469