aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolodymyr Vysotskyi <vvovyk@gmail.com>2019-01-21 03:47:59 +0200
committerVolodymyr Vysotskyi <vvovyk@gmail.com>2019-01-25 17:33:36 +0200
commit5026cd12e317e71c4dac1561c347991a36c94e4d (patch)
treeb6e2e5cb4bc4b8039a2dc04984cb0fffbcb232ea
parenta00f1800b95a007b0890f97fd260a6085911438b (diff)
DRILL-6985: Fix sqlline.bat issues on Windows and add drill-embedded.bat
closes #1616
-rw-r--r--distribution/src/assemble/component.xml6
-rw-r--r--distribution/src/resources/drill-embedded.bat24
-rwxr-xr-xdistribution/src/resources/sqlline.bat41
3 files changed, 46 insertions, 25 deletions
diff --git a/distribution/src/assemble/component.xml b/distribution/src/assemble/component.xml
index 2b6029954..a79a4fa35 100644
--- a/distribution/src/assemble/component.xml
+++ b/distribution/src/assemble/component.xml
@@ -311,6 +311,11 @@
<outputDirectory>bin</outputDirectory>
</file>
<file>
+ <source>src/resources/drill-embedded.bat</source>
+ <fileMode>0755</fileMode>
+ <outputDirectory>bin</outputDirectory>
+ </file>
+ <file>
<source>src/resources/drill-localhost</source>
<fileMode>0755</fileMode>
<outputDirectory>bin</outputDirectory>
@@ -327,6 +332,7 @@
</file>
<file>
<source>src/resources/sqlline.bat</source>
+ <fileMode>0755</fileMode>
<outputDirectory>bin</outputDirectory>
</file>
<file>
diff --git a/distribution/src/resources/drill-embedded.bat b/distribution/src/resources/drill-embedded.bat
new file mode 100644
index 000000000..bf38db14d
--- /dev/null
+++ b/distribution/src/resources/drill-embedded.bat
@@ -0,0 +1,24 @@
+@REM
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM
+
+@echo off
+setlocal EnableExtensions EnableDelayedExpansion
+
+set BIN_DIR=%~dp0
+pushd %BIN_DIR%
+call sqlline.bat -u "jdbc:drill:zk=local" %*
diff --git a/distribution/src/resources/sqlline.bat b/distribution/src/resources/sqlline.bat
index 40f277115..360b758f0 100755
--- a/distribution/src/resources/sqlline.bat
+++ b/distribution/src/resources/sqlline.bat
@@ -17,27 +17,19 @@
@REM
@echo off
-@rem/*
-@rem * Licensed to the Apache Software Foundation (ASF) under one
-@rem * or more contributor license agreements. See the NOTICE file
-@rem * distributed with this work for additional information
-@rem * regarding copyright ownership. The ASF licenses this file
-@rem * to you under the Apache License, Version 2.0 (the
-@rem * "License"); you may not use this file except in compliance
-@rem * with the License. You may obtain a copy of the License at
-@rem *
-@rem * http://www.apache.org/licenses/LICENSE-2.0
-@rem *
-@rem * Unless required by applicable law or agreed to in writing, software
-@rem * distributed under the License is distributed on an "AS IS" BASIS,
-@rem * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem * See the License for the specific language governing permissions and
-@rem * limitations under the License.
-@rem */
-@rem
setlocal EnableExtensions EnableDelayedExpansion
rem ----
+rem Sets Drill home and bin dirs before shift is applied
+rem to preserve correct paths
+rem ----
+
+set DRILL_BIN_DIR=%~dp0
+pushd %DRILL_BIN_DIR%..
+set DRILL_HOME=%cd%
+popd
+
+rem ----
rem In order to pass in arguments with an equals symbol, use quotation marks.
rem For example
rem sqlline -u "jdbc:drill:zk=local" -n admin -p admin
@@ -54,6 +46,7 @@ set atleastonearg=0
if x%1 == x-q (
set QUERY=%2
+ set QUERY=!QUERY:"=!
set atleastonearg=1
shift
shift
@@ -61,6 +54,7 @@ if x%1 == x-q (
if x%1 == x-e (
set QUERY=%2
+ set QUERY=!QUERY:"=!
set atleastonearg=1
shift
shift
@@ -68,6 +62,7 @@ if x%1 == x-e (
if x%1 == x-f (
set FILE=%2
+ set FILE=!FILE:"=!
set atleastonearg=1
shift
shift
@@ -76,6 +71,7 @@ if x%1 == x-f (
if x%1 == x--config (
set confdir=%2
set DRILL_CONF_DIR=%2
+ set DRILL_CONF_DIR=!DRILL_CONF_DIR:"=!
set atleastonearg=1
shift
shift
@@ -127,11 +123,6 @@ rem ----
rem Deal with Drill variables
rem ----
-set DRILL_BIN_DIR=%~dp0
-pushd %DRILL_BIN_DIR%..
-set DRILL_HOME=%cd%
-popd
-
if "test%DRILL_CONF_DIR%" == "test" (
set DRILL_CONF_DIR=%DRILL_HOME%\conf
)
@@ -219,10 +210,10 @@ if errorlevel 1 (
set SQLLINE_CALL=sqlline.SqlLine -ac org.apache.drill.exec.client.DrillSqlLineApplication -d org.apache.drill.jdbc.Driver
if NOT "test%QUERY%"=="test" (
- echo %QUERY% | "%JAVA_CMD%" %DRILL_SHELL_JAVA_OPTS% %DRILL_JAVA_OPTS% -cp "%DRILL_CP%" %SQLLINE_CALL% %DRILL_ARGS%
+ "%JAVA_CMD%" %DRILL_SHELL_JAVA_OPTS% %DRILL_JAVA_OPTS% -cp "%DRILL_CP%" %SQLLINE_CALL% %DRILL_ARGS% -e "%QUERY%"
) else (
if NOT "test%FILE%"=="test" (
- "%JAVA_CMD%" %DRILL_SHELL_JAVA_OPTS% %DRILL_JAVA_OPTS% -cp "%DRILL_CP%" %SQLLINE_CALL% %DRILL_ARGS% --run=%FILE%
+ "%JAVA_CMD%" %DRILL_SHELL_JAVA_OPTS% %DRILL_JAVA_OPTS% -cp "%DRILL_CP%" %SQLLINE_CALL% %DRILL_ARGS% --run="%FILE%"
) else (
"%JAVA_CMD%" %DRILL_SHELL_JAVA_OPTS% %DRILL_JAVA_OPTS% -cp "%DRILL_CP%" %SQLLINE_CALL% %DRILL_ARGS%
)