forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-8607] [table] Add a basic embedded SQL CLI client
This closes apache#5441.
- Loading branch information
Showing
59 changed files
with
6,252 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/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. | ||
################################################################################ | ||
|
||
################################################################################ | ||
# Adopted from "flink" bash script | ||
################################################################################ | ||
|
||
target="$0" | ||
# For the case, the executable has been directly symlinked, figure out | ||
# the correct bin path by following its symlink up to an upper bound. | ||
# Note: we can't use the readlink utility here if we want to be POSIX | ||
# compatible. | ||
iteration=0 | ||
while [ -L "$target" ]; do | ||
if [ "$iteration" -gt 100 ]; then | ||
echo "Cannot resolve path: You have a cyclic symlink in $target." | ||
break | ||
fi | ||
ls=`ls -ld -- "$target"` | ||
target=`expr "$ls" : '.* -> \(.*\)$'` | ||
iteration=$((iteration + 1)) | ||
done | ||
|
||
# Convert relative path to absolute path | ||
bin=`dirname "$target"` | ||
|
||
# get flink config | ||
. "$bin"/config.sh | ||
|
||
if [ "$FLINK_IDENT_STRING" = "" ]; then | ||
FLINK_IDENT_STRING="$USER" | ||
fi | ||
|
||
CC_CLASSPATH=`constructFlinkClassPath` | ||
|
||
################################################################################ | ||
# SQL client specific logic | ||
################################################################################ | ||
|
||
log=$FLINK_LOG_DIR/flink-$FLINK_IDENT_STRING-sql-client-$HOSTNAME.log | ||
log_setting=(-Dlog.file="$log" -Dlog4j.configuration=file:"$FLINK_CONF_DIR"/log4j-cli.properties -Dlogback.configurationFile=file:"$FLINK_CONF_DIR"/logback.xml) | ||
|
||
export FLINK_ROOT_DIR | ||
export FLINK_CONF_DIR | ||
|
||
# get path of jar in /opt if it exist | ||
FLINK_SQL_CLIENT_JAR=$(find "$FLINK_OPT_DIR" -regex ".*flink-sql-client.*.jar") | ||
|
||
# check if SQL client is already in classpath and must not be shipped manually | ||
if [[ "$CC_CLASSPATH" =~ .*flink-sql-client.*.jar ]]; then | ||
|
||
# start client without jar | ||
exec $JAVA_RUN $JVM_ARGS "${log_setting[@]}" -classpath "`manglePathList "$CC_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" org.apache.flink.table.client.SqlClient "$@" | ||
|
||
# check if SQL client jar is in /opt | ||
elif [ -n "$FLINK_SQL_CLIENT_JAR" ]; then | ||
|
||
# start client with jar | ||
exec $JAVA_RUN $JVM_ARGS "${log_setting[@]}" -classpath "`manglePathList "$CC_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS:$FLINK_SQL_CLIENT_JAR"`" org.apache.flink.table.client.SqlClient "$@" --jar "`manglePath $FLINK_SQL_CLIENT_JAR`" | ||
|
||
# write error message to stderr | ||
else | ||
(>&2 echo "[ERROR] Flink SQL Client JAR file 'flink-sql-client*.jar' neither found in classpath nor /opt directory should be located in $FLINK_OPT_DIR.") | ||
|
||
# exit to force process failure | ||
exit 1 | ||
fi |
64 changes: 64 additions & 0 deletions
64
flink-libraries/flink-sql-client/conf/sql-client-defaults.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
################################################################################ | ||
# 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. | ||
################################################################################ | ||
|
||
|
||
# This file defines the default environment for Flink's SQL Client. | ||
# Defaults might be overwritten by a session specific environment. | ||
|
||
|
||
#============================================================================== | ||
# Table Sources | ||
#============================================================================== | ||
|
||
# Define table sources here. See the Table API & SQL documentation for details. | ||
|
||
sources: [] # empty list | ||
# A typical table source definition looks like: | ||
# - name: ... | ||
# connector: ... | ||
# format: ... | ||
# schema: ... | ||
|
||
#============================================================================== | ||
# Execution properties | ||
#============================================================================== | ||
|
||
# Execution properties allow for changing the behavior of a table program. | ||
|
||
execution: | ||
type: streaming # 'batch' or 'streaming' execution | ||
result-mode: changelog # 'changelog' or 'table' presentation of results | ||
parallelism: 1 # parallelism of the program | ||
max-parallelism: 128 # maximum parallelism | ||
min-idle-state-retention: 0 # minimum idle state retention in ms | ||
max-idle-state-retention: 0 # maximum idle state retention in ms | ||
|
||
#============================================================================== | ||
# Deployment properties | ||
#============================================================================== | ||
|
||
# Deployment properties allow for describing the cluster to which table | ||
# programs are submitted to. | ||
|
||
deployment: | ||
type: standalone # only the 'standalone' deployment is supported | ||
response-timeout: 5000 # general cluster communication timeout in ms | ||
gateway-address: "" # (optional) address from cluster to gateway | ||
gateway-port: 0 # (optional) port from cluster to gateway | ||
|
||
|
Oops, something went wrong.