#!/usr/bin/env bash

#
# DATABRICKS CONFIDENTIAL & PROPRIETARY
# __________________
#
# Copyright 2019 Databricks, Inc.
# All Rights Reserved.
#
# NOTICE:  All information contained herein is, and remains the property of Databricks, Inc.
# and its suppliers, if any.  The intellectual and technical concepts contained herein are
# proprietary to Databricks, Inc. and its suppliers and may be covered by U.S. and foreign Patents,
# patents in process, and are protected by trade secret and/or copyright law. Dissemination, use,
# or reproduction of this information is strictly forbidden unless prior written permission is
# obtained from Databricks, Inc.
#
# If you view or obtain a copy of this information and believe Databricks, Inc. may not have
# intended it to be made available, please promptly report it to Databricks Legal Department
# @ legal@databricks.com.
#

# Shell script for starting the PySpark Shell REPL using Bazel

set -euo pipefail

bazel build //repl //sql/hive:hive-unshaded_2.12
export BAZEL_SPARK_SUBMIT
BAZEL_SPARK_SUBMIT="$(cat bazel-bin/repl/repl-jetty9-hadoop1_2.12.runtimeclasspath.txt bazel-bin/sql/hive/hive-unshaded_2.12.runtimeclasspath.txt | tr '\n' ':')"

GIT_ROOT="$(git rev-parse --show-toplevel)"

"$GIT_ROOT/bin/pyspark" "$@"
