Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions bin/hplsql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env bash
# 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.

set -eo pipefail

curdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"

if [[ "$(uname -s)" == 'Darwin' ]] && command -v brew &>/dev/null; then
PATH="$(brew --prefix)/opt/gnu-getopt/bin:${PATH}"
export PATH
fi

DORIS_HOME="$(
cd "${curdir}/.."
pwd
)"
export DORIS_HOME

# JAVA_OPTS
# LOG_DIR
# PID_DIR
export JAVA_OPTS="-Xmx4096m"
PID_DIR="$(
cd "${curdir}"
pwd
)"
export PID_DIR
if [[ -z "${JAVA_HOME}" ]]; then
JAVA="$(command -v java)"
else
JAVA="${JAVA_HOME}/bin/java"
fi

if [[ ! -x "${JAVA}" ]]; then
echo "The JAVA_HOME environment variable is not defined correctly"
echo "This environment variable is needed to run this program"
echo "NB: JAVA_HOME should point to a JDK not a JRE"
exit 1
fi

# get jdk version, return version as an Integer.
# 1.8 => 8, 13.0 => 13
jdk_version() {
local java_cmd="${1}"
local result
local IFS=$'\n'

if [[ -z "${java_cmd}" ]]; then
result=no_java
return 1
else
local version
# remove \r for Cygwin
version="$("${java_cmd}" -Xms32M -Xmx32M -version 2>&1 | tr '\r' '\n' | grep version | awk '{print $3}')"
version="${version//\"/}"
if [[ "${version}" =~ ^1\. ]]; then
result="$(echo "${version}" | awk -F '.' '{print $2}')"
else
result="$(echo "${version}" | awk -F '.' '{print $1}')"
fi
fi
echo "${result}"
return 0
}

final_java_opt="${JAVA_OPTS}"

# add libs to CLASSPATH
DORIS_FE_JAR=
for f in "${DORIS_HOME}/lib"/*.jar; do
if [[ "${f}" == *"doris-fe.jar" ]]; then
DORIS_FE_JAR="${f}"
continue
fi
CLASSPATH="${f}:${CLASSPATH}"
done

# make sure the doris-fe.jar is at first order, so that some classed
# with same qualified name can be loaded priority from doris-fe.jar
CLASSPATH="${DORIS_FE_JAR}:${CLASSPATH}"
export CLASSPATH="${CLASSPATH}:${DORIS_HOME}/lib:${DORIS_HOME}/conf"

if [[ ! -f "/bin/limit" ]]; then
LIMIT=''
else
LIMIT=/bin/limit
fi

${LIMIT:+${LIMIT}} "${JAVA}" ${final_java_opt:+${final_java_opt}} -XX:-OmitStackTraceInFastThrow -XX:OnOutOfMemoryError="kill -9 %p" org.apache.doris.hplsql.Hplsql ${HELPER:+${HELPER}} ${OPT_VERSION:+${OPT_VERSION}} "$@" </dev/null
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ if [[ "${BUILD_FE}" -eq 1 ]]; then
"${DORIS_OUTPUT}/fe/webroot" "${DORIS_OUTPUT}/fe/lib"

cp -r -p "${DORIS_HOME}/bin"/*_fe.sh "${DORIS_OUTPUT}/fe/bin"/
cp -r -p "${DORIS_HOME}/bin"/hplsql.sh "${DORIS_OUTPUT}/fe/bin"/
cp -r -p "${DORIS_HOME}/conf/fe.conf" "${DORIS_OUTPUT}/fe/conf"/
cp -r -p "${DORIS_HOME}/conf/ldap.conf" "${DORIS_OUTPUT}/fe/conf"/
cp -r -p "${DORIS_HOME}/conf/mysql_ssl_default_certificate" "${DORIS_OUTPUT}/fe/"/
Expand Down
62 changes: 62 additions & 0 deletions conf/hplsql-site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
<name>hplsql.conn.default</name>
<value>dorisconn</value>
<description>The default connection profile</description>
</property>
<property>
<name>hplsql.conn.dorisconn</name>
<value>com.mysql.cj.jdbc.Driver;jdbc:mysql://fehost:queryport/information_schema;user;password</value>
<description>Doris jdbc connection</description>
</property>
<property>
<name>hplsql.dual.table</name>
<value></value>
<description>Single row, single column table for internal operations</description>
</property>
<property>
<name>hplsql.insert.values</name>
<value>native</value>
<description>How to execute INSERT VALUES statement: native (default) and select</description>
</property>
<property>
<name>hplsql.onerror</name>
<value>exception</value>
<description>Error handling behavior: exception (default), seterror and stop</description>
</property>
<property>
<name>hplsql.temp.tables</name>
<value>native</value>
<description>Temporary tables: native (default) and managed</description>
</property>
<property>
<name>hplsql.temp.tables.schema</name>
<value></value>
<description>Schema for managed temporary tables</description>
</property>
<property>
<name>hplsql.temp.tables.location</name>
<value>/tmp/plhql</value>
<description>LOcation for managed temporary tables in HDFS</description>
</property>
</configuration>

Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,62 @@
// TYPE codes are defined in the file 'mysql/include/mysql_com.h' enum enum_field_types
// which is also demostrated in
// http://dev.mysql.com/doc/internals/en/com-query-response.html
// typeName from https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html
public enum MysqlColType {
MYSQL_TYPE_DECIMAL(0, "DECIMAL"),
MYSQL_TYPE_TINY(1, "TINY INT"),
MYSQL_TYPE_SHORT(2, "SMALL INT"),
MYSQL_TYPE_LONG(3, "INT"),
MYSQL_TYPE_FLOAT(4, "FLOAT"),
MYSQL_TYPE_DOUBLE(5, "DOUBLE"),
MYSQL_TYPE_NULL(6, "NULL"),
MYSQL_TYPE_TIMESTAMP(7, "TIMESTAMP"),
MYSQL_TYPE_LONGLONG(8, "LONGLONG"),
MYSQL_TYPE_INT24(9, "INT24"),
MYSQL_TYPE_DATE(10, "DATE"),
MYSQL_TYPE_TIME(11, "TIME"),
MYSQL_TYPE_DATETIME(12, "DATETIME"),
MYSQL_TYPE_YEAR(13, "YEAR"),
MYSQL_TYPE_NEWDATE(14, "NEWDATE"),
MYSQL_TYPE_VARCHAR(15, "VARCHAR"),
MYSQL_TYPE_BIT(16, "BIT"),
MYSQL_TYPE_TIMESTAMP2(17, "TIMESTAMP2"),
MYSQL_TYPE_DATETIME2(18, "DATETIME2"),
MYSQL_TYPE_TIME2(19, "TIME2"),
MYSQL_TYPE_JSON(245, "JSON"),
MYSQL_TYPE_NEWDECIMAL(246, "NEW DECIMAL"),
MYSQL_TYPE_ENUM(247, "ENUM"),
MYSQL_TYPE_SET(248, "SET"),
MYSQL_TYPE_TINY_BLOB(249, "TINY BLOB"),
MYSQL_TYPE_MEDIUM_BLOB(250, "MEDIUM BLOB"),
MYSQL_TYPE_LONG_BLOB(251, "LONG BLOB"),
MYSQL_TYPE_BLOB(252, "BLOB"),
MYSQL_TYPE_VARSTRING(253, "VAR STRING"),
MYSQL_TYPE_STRING(254, "STRING"),
MYSQL_TYPE_GEOMETRY(255, "GEOMETRY"),
MYSQL_TYPE_MAP(400, "MAP");
MYSQL_TYPE_DECIMAL(0, "DECIMAL", "DECIMAL"),
MYSQL_TYPE_TINY(1, "TINYINT", "TINY INT"),
MYSQL_TYPE_SHORT(2, "SMALLINT", "SMALL INT"),
MYSQL_TYPE_LONG(3, "INTEGER", "INT"),
MYSQL_TYPE_FLOAT(4, "FLOAT", "FLOAT"),
MYSQL_TYPE_DOUBLE(5, "DOUBLE", "DOUBLE"),
MYSQL_TYPE_NULL(6, "NULL", "NULL"),
MYSQL_TYPE_TIMESTAMP(7, "TIMESTAMP", "TIMESTAMP"),
MYSQL_TYPE_LONGLONG(8, "BIGINT", "LONGLONG"),
MYSQL_TYPE_INT24(9, "INT24", "INT24"),
MYSQL_TYPE_DATE(10, "DATE", "DATE"),
MYSQL_TYPE_TIME(11, "TIME", "TIME"),
MYSQL_TYPE_DATETIME(12, "DATETIME", "DATETIME"),
MYSQL_TYPE_YEAR(13, "YEAR", "YEAR"),
MYSQL_TYPE_NEWDATE(14, "NEWDATE", "NEWDATE"),
MYSQL_TYPE_VARCHAR(15, "VARCHAR", "VARCHAR"),
MYSQL_TYPE_BIT(16, "BIT", "BIT"),
MYSQL_TYPE_TIMESTAMP2(17, "TIMESTAMP2", "TIMESTAMP2"),
MYSQL_TYPE_DATETIME2(18, "DATETIME2", "DATETIME2"),
MYSQL_TYPE_TIME2(19, "TIME2", "TIME2"),
MYSQL_TYPE_JSON(245, "JSON", "JSON"),
MYSQL_TYPE_NEWDECIMAL(246, "NEWDECIMAL", "NEW DECIMAL"),
MYSQL_TYPE_ENUM(247, "CHAR", "ENUM"),
MYSQL_TYPE_SET(248, "CHAR", "SET"),
MYSQL_TYPE_TINY_BLOB(249, "TINYBLOB", "TINY BLOB"),
MYSQL_TYPE_MEDIUM_BLOB(250, "MEDIUMBLOB", "MEDIUM BLOB"),
MYSQL_TYPE_LONG_BLOB(251, "LONGBLOB", "LONG BLOB"),
MYSQL_TYPE_BLOB(252, "BLOB", "BLOB"),
MYSQL_TYPE_VARSTRING(253, "VARSTRING", "VAR STRING"),
MYSQL_TYPE_STRING(254, "CHAR", "STRING"),
MYSQL_TYPE_GEOMETRY(255, "GEOMETRY", "GEOMETRY"),
MYSQL_TYPE_MAP(400, "MAP", "MAP");

private MysqlColType(int code, String desc) {
private MysqlColType(int code, String typeName, String desc) {
this.code = code;
this.typeName = typeName;
this.desc = desc;
}

// used in network
private int code;

private String typeName;

private String desc;

public int getCode() {
return code;
}

public String getTypeName() {
return typeName;
}

@Override
public String toString() {
return desc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Lists;

import java.sql.Types;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -1214,6 +1215,52 @@ public MysqlColType toMysqlType() {
}
}

public int toJavaSqlType() {
switch (this) {
case BOOLEAN:
return Types.BOOLEAN;
case TINYINT:
return Types.TINYINT;
case SMALLINT:
return Types.SMALLINT;
case INT:
return Types.INTEGER;
case BIGINT:
return Types.BIGINT;
case FLOAT:
return Types.FLOAT;
case DOUBLE:
return Types.DOUBLE;
case TIME:
case TIMEV2:
return Types.TIME;
case DATE:
case DATEV2:
return Types.DATE;
case DATETIME:
case DATETIMEV2: {
if (isTimeType) {
return Types.TIME;
} else {
return Types.DATE;
}
}
case DECIMALV2:
case DECIMAL32:
case DECIMAL64:
case DECIMAL128:
return Types.DECIMAL;
case VARCHAR:
return Types.VARCHAR;
case ARRAY:
return Types.ARRAY;
case STRUCT:
return Types.STRUCT;
default:
return Types.CHAR;
}
}

public int getOlapColumnIndexSize() {
switch (this) {
case DATE:
Expand Down
4 changes: 4 additions & 0 deletions fe/fe-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ under the License.
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>

<!-- antl4 -->
<dependency>
Expand Down
Loading