Skip to content

Commit a1877f4

Browse files
HyukjinKwoncloud-fan
authored andcommitted
[SPARK-22597][SQL] Add spark-sql cmd script for Windows users
## What changes were proposed in this pull request? This PR proposes to add cmd scripts so that Windows users can also run `spark-sql` script. ## How was this patch tested? Manually tested on Windows. **Before** ```cmd C:\...\spark>.\bin\spark-sql '.\bin\spark-sql' is not recognized as an internal or external command, operable program or batch file. C:\...\spark>.\bin\spark-sql.cmd '.\bin\spark-sql.cmd' is not recognized as an internal or external command, operable program or batch file. ``` **After** ```cmd C:\...\spark>.\bin\spark-sql ... spark-sql> SELECT 'Hello World !!'; ... Hello World !! ``` Author: hyukjinkwon <[email protected]> Closes #19808 from HyukjinKwon/spark-sql-cmd.
1 parent efd0036 commit a1877f4

File tree

5 files changed

+53
-4
lines changed

5 files changed

+53
-4
lines changed

bin/find-spark-home.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if not "x%PYSPARK_PYTHON%"=="x" (
3232
)
3333

3434
rem If there is python installed, trying to use the root dir as SPARK_HOME
35-
where %PYTHON_RUNNER% > nul 2>$1
35+
where %PYTHON_RUNNER% > nul 2>&1
3636
if %ERRORLEVEL% neq 0 (
3737
if not exist %PYTHON_RUNNER% (
3838
if "x%SPARK_HOME%"=="x" (

bin/run-example.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ rem
2020
rem Figure out where the Spark framework is installed
2121
call "%~dp0find-spark-home.cmd"
2222

23-
set _SPARK_CMD_USAGE=Usage: ./bin/run-example [options] example-class [example args]
23+
set _SPARK_CMD_USAGE=Usage: .\bin\run-example [options] example-class [example args]
2424

2525
rem The outermost quotes are used to prevent Windows command line parse error
2626
rem when there are some quotes in parameters, see SPARK-21877.

bin/spark-sql.cmd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@echo off
2+
3+
rem
4+
rem Licensed to the Apache Software Foundation (ASF) under one or more
5+
rem contributor license agreements. See the NOTICE file distributed with
6+
rem this work for additional information regarding copyright ownership.
7+
rem The ASF licenses this file to You under the Apache License, Version 2.0
8+
rem (the "License"); you may not use this file except in compliance with
9+
rem the License. You may obtain a copy of the License at
10+
rem
11+
rem http://www.apache.org/licenses/LICENSE-2.0
12+
rem
13+
rem Unless required by applicable law or agreed to in writing, software
14+
rem distributed under the License is distributed on an "AS IS" BASIS,
15+
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
rem See the License for the specific language governing permissions and
17+
rem limitations under the License.
18+
rem
19+
20+
rem This is the entry point for running SparkSQL. To avoid polluting the
21+
rem environment, it just launches a new cmd to do the real work.
22+
23+
rem The outermost quotes are used to prevent Windows command line parse error
24+
rem when there are some quotes in parameters, see SPARK-21877.
25+
cmd /V /E /C ""%~dp0spark-sql2.cmd" %*"

bin/spark-sql2.cmd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@echo off
2+
3+
rem
4+
rem Licensed to the Apache Software Foundation (ASF) under one or more
5+
rem contributor license agreements. See the NOTICE file distributed with
6+
rem this work for additional information regarding copyright ownership.
7+
rem The ASF licenses this file to You under the Apache License, Version 2.0
8+
rem (the "License"); you may not use this file except in compliance with
9+
rem the License. You may obtain a copy of the License at
10+
rem
11+
rem http://www.apache.org/licenses/LICENSE-2.0
12+
rem
13+
rem Unless required by applicable law or agreed to in writing, software
14+
rem distributed under the License is distributed on an "AS IS" BASIS,
15+
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
rem See the License for the specific language governing permissions and
17+
rem limitations under the License.
18+
rem
19+
20+
rem Figure out where the Spark framework is installed
21+
call "%~dp0find-spark-home.cmd"
22+
23+
set _SPARK_CMD_USAGE=Usage: .\bin\spark-sql [options] [cli option]
24+
25+
call "%SPARK_HOME%\bin\spark-submit2.cmd" --class org.apache.spark.sql.hive.thriftserver.SparkSQLCLIDriver %*

bin/sparkR2.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@ rem Figure out where the Spark framework is installed
2121
call "%~dp0find-spark-home.cmd"
2222

2323
call "%SPARK_HOME%\bin\load-spark-env.cmd"
24-
25-
24+
set _SPARK_CMD_USAGE=Usage: .\bin\sparkR [options]
2625
call "%SPARK_HOME%\bin\spark-submit2.cmd" sparkr-shell-main %*

0 commit comments

Comments
 (0)