[ 
https://issues.apache.org/jira/browse/KYLIN-4491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17107424#comment-17107424
 ] 

ASF GitHub Bot commented on KYLIN-4491:
---------------------------------------

hit-lacus commented on a change in pull request #1209:
URL: https://github.com/apache/kylin/pull/1209#discussion_r425240706



##########
File path: 
datasource-sdk/src/main/java/org/apache/kylin/sdk/datasource/adaptor/PrestoAdaptor.java
##########
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kylin.sdk.datasource.adaptor;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.sql.rowset.CachedRowSet;
+
+public class PrestoAdaptor extends DefaultAdaptor {
+
+    private Pattern patternASYM = Pattern.compile("BETWEEN(\\s*)ASYMMETRIC");
+    private Pattern patternSYM = Pattern.compile("BETWEEN(\\s*)SYMMETRIC");
+    private Pattern patternTrim = 
Pattern.compile("TRIM\\(.*BOTH.*FROM\\s+(.+)\\)");
+    private Pattern patternOffset = Pattern.compile("(?i)OFFSET\\s\\d+");
+
+    public PrestoAdaptor(AdaptorConfig config) throws Exception {
+        super(config);
+    }
+
+    @Override
+    public String fixSql(String sql) {
+        sql = resolveBetweenAsymmetricSymmetric(sql);
+        sql = convertTrim(sql);
+        sql = convertOffset(sql);
+        return sql;
+    }
+
+    @Override
+    public int toKylinTypeId(String type, int typeId) {
+        if (2000 == typeId) {

Review comment:
       Could you please kindly explain the magic number `2000` means? I check 
the [JDK7 Constant 
value](https://docs.oracle.com/javase/7/docs/api/constant-values.html), 2000 is 
refer to `JAVA_OBJECT`, am I right?

##########
File path: datasource-sdk/src/main/resources/datasource/default.xml
##########
@@ -170,6 +170,34 @@
     <FUNCTION_DEF ID="82" EXPRESSION="CORR($0, $1)"/>
     <!--Random number-->
     <FUNCTION_DEF ID="83" EXPRESSION="RAND()"/>
+    <!--RAND_INTEGER-->
+    <FUNCTION_DEF ID="92" EXPRESSION="RAND_INTEGER($0, $1)"/>

Review comment:
       Should we start the `ID` from 84 other than 92?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Query push down to Presto
> -------------------------
>
>                 Key: KYLIN-4491
>                 URL: https://issues.apache.org/jira/browse/KYLIN-4491
>             Project: Kylin
>          Issue Type: New Feature
>          Components: Integration, RDBMS Source
>            Reporter: Shao Feng Shi
>            Priority: Major
>             Fix For: v3.1.0
>
>
> With the data source SDK, we can push down a query to Presto instead of Hive 
> or Spark to gain better performance; With the SDK, we can also convert 
> Kylin's SQL query to Presto SQL. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to