diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb4e2d1..3c87f09 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,9 +16,10 @@ on: jobs: build: - runs-on: ubuntu-latest - + strategy: + matrix: + scala: [2.12, 2.11] steps: - uses: actions/checkout@v3 - name: Set up JDK 1.8 @@ -27,5 +28,11 @@ jobs: java-version: 8 distribution: 'temurin' cache: maven + - name: Change scala version to ${{matrix.scala}} + run: bash ./build/change-scala-version.sh ${{matrix.scala}} - name: Build with Maven run: mvn -B package --file pom.xml + - uses: actions/upload-artifact@v3 + with: + name: geomesa-sql-dist-package-${{matrix.scala}} + path: geomesa-sql-dist/target/*.tar.gz diff --git a/build/change-scala-version.sh b/build/change-scala-version.sh new file mode 100755 index 0000000..f440e4c --- /dev/null +++ b/build/change-scala-version.sh @@ -0,0 +1,80 @@ +#!/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 -e + +VALID_VERSIONS=( 2.11 2.12 ) + +SCALA_2_11_VERSION="2.11.7" +SCALA_2_12_VERSION="2.12.13" + +usage() { + echo "Usage: $(basename $0) [-h|--help] +where : + -h| --help Display this help text + valid version values : ${VALID_VERSIONS[*]} +" 1>&2 + exit 1 +} + +if [[ ($# -ne 1) || ( $1 == "--help") || $1 == "-h" ]]; then + usage +fi + +TO_VERSION=$1 + +check_scala_version() { + for i in ${VALID_VERSIONS[*]}; do [ $i = "$1" ] && return 0; done + echo "Invalid Scala version: $1. Valid versions: ${VALID_VERSIONS[*]}" 1>&2 + exit 1 +} + +check_scala_version "$TO_VERSION" + +if [ $TO_VERSION = "2.12" ]; then + FULL_VERSION="2.12.13" + FROM_VERSION="2.11" +else + FULL_VERSION="2.11.7" + FROM_VERSION="2.12" +fi + +sed_i() { + sed -e "$1" "$2" > "$2.tmp" && mv "$2.tmp" "$2" +} + +export -f sed_i + +BASEDIR=$(dirname $0)/.. +find "$BASEDIR" -name 'pom.xml' -not -path '*target*' -print \ + -exec bash -c "sed_i 's/\(artifactId.*\)_'$FROM_VERSION'/\1_'$TO_VERSION'/g' {}" \; + +# Also update in parent POM +# Match any scala binary version to ensure idempotency +sed_i '1,/[0-9]*\.[0-9]*[0-9]*\.[0-9]*'$TO_VERSION' in parent POM +sed_i '1,/[0-9]*\.[0-9]*\.[0-9]*[0-9]*\.[0-9]*\.[0-9]*'$FULL_VERSION'\*:\*_'$TO_VERSION'|*:*_'$FROM_VERSION'|' "$BASEDIR/pom.xml" +sed_i 's|'$FROM_VERSION'\.\*|'$TO_VERSION'.*|' "$BASEDIR/pom.xml" +sed_i 's|'$FROM_VERSION'|'$TO_VERSION'|' "$BASEDIR/pom.xml" diff --git a/geomesa-sql-cli/bin/geomesa-sqlline b/geomesa-sql-cli/bin/geomesa-sqlline index 29b0c66..ed3d215 100755 --- a/geomesa-sql-cli/bin/geomesa-sqlline +++ b/geomesa-sql-cli/bin/geomesa-sqlline @@ -22,6 +22,8 @@ script_dir=$(dirname $script_file) GEOMESA_SQL_HOME=$(dirname $script_dir) GEOMESA_SQL_CONF_PATH="${GEOMESA_SQL_HOME}/conf" GEOMESA_HOME="${GEOMESA_HOME:-$GEOMESA_SQL_HOME}" +GEOMESA_CONF_DIR="${GEOMESA_CONF_DIR:-$GEOMESA_HOME/conf}" +GEOMESA_LOG_DIR="${GEOMESA_LOG_DIR:-$GEOMESA_HOME/logs}" # Sanity checks for GEOMESA_HOME if [ ! -d "$GEOMESA_HOME" ]; then @@ -89,7 +91,7 @@ usage() { exit 1; } -while getopts ":c:p:h" o; do +while getopts ":c:p:f:e:h" o; do case "$o" in c) CATALOG=${OPTARG} @@ -97,6 +99,12 @@ while getopts ":c:p:h" o; do p) DS_PARAMS=${OPTARG} ;; + f) + INPUT_FILE=${OPTARG} + ;; + e) + SQL=${OPTARG} + ;; h) usage esac @@ -122,8 +130,23 @@ fi GEOMESA_CLASSPATH=$(${GEOMESA_HOME}/bin/${GEOMESA_TOOL_NAME} classpath | tr '\n' ':') JDBC_URL="jdbc:geomesa:${CATALOG_PROP_NAME}=${CATALOG};fun=spatial;caseSensitive=false;${DS_PARAMS}" -$RUNNER -classpath "${GEOMESA_CLASSPATH}:${GEOMESA_SQL_CONF_PATH}:${GEOMESA_SQL_CLI_JAR_PATH}" \ - sqlline.SqlLine \ - --verbose=true \ - --connectInteractionMode=notAskCredentials \ - -u "$JDBC_URL" +mkdir -p "${GEOMESA_LOG_DIR}" + +ARGS=("-u" "$JDBC_URL") +if [ -n "$INPUT_FILE" ]; then + ARGS+=("-f" "$INPUT_FILE") +fi +if [ -n "$SQL" ]; then + ARGS+=("-e" "$SQL") +fi + +$RUNNER \ + -Dlog4j.configuration=file://${GEOMESA_CONF_DIR}/log4j.properties \ + -Dgeomesa.home=${GEOMESA_HOME} \ + -Dgeomesa.log.dir=${GEOMESA_LOG_DIR} \ + -classpath "${GEOMESA_CLASSPATH}:${GEOMESA_SQL_CONF_PATH}:${GEOMESA_SQL_CLI_JAR_PATH}" \ + sqlline.SqlLine \ + --verbose=true \ + --connectInteractionMode=notAskCredentials \ + -u "$JDBC_URL" \ + "${ARGS[@]}" diff --git a/geomesa-sql-core/src/test/scala/com/spatialx/geomesa/sql/FilterTest.scala b/geomesa-sql-core/src/test/scala/com/spatialx/geomesa/sql/FilterTest.scala index a84d412..7e55e07 100644 --- a/geomesa-sql-core/src/test/scala/com/spatialx/geomesa/sql/FilterTest.scala +++ b/geomesa-sql-core/src/test/scala/com/spatialx/geomesa/sql/FilterTest.scala @@ -202,7 +202,7 @@ class FilterTest extends Specification { "ST_Contains(ST_MakeEnvelope(3, 3, 8, 8), pt)", "ST_Crosses(ST_MakeEnvelope(3, 3, 8, 8), line)", "ST_Overlaps(ST_MakeEnvelope(10, 10, 80, 80), poly)", - "ST_DWithin(ST_MakeEnvelope(3, 3, 8, 8), pt, 5)", + "ST_DWithin(ST_MakeEnvelope(3, 3, 8, 8), pt, 5)" ) Result.foreach(predicates) { predicate => verifyGeometry(s"SELECT * FROM TEST_GEOM_DATA WHERE $predicate", diff --git a/geomesa-sql-jdbc/src/main/scala/com/spatialx/geomesa/sql/jdbc/Driver.scala b/geomesa-sql-jdbc/src/main/scala/com/spatialx/geomesa/sql/jdbc/Driver.scala index 9b20a34..e8e4d02 100644 --- a/geomesa-sql-jdbc/src/main/scala/com/spatialx/geomesa/sql/jdbc/Driver.scala +++ b/geomesa-sql-jdbc/src/main/scala/com/spatialx/geomesa/sql/jdbc/Driver.scala @@ -113,7 +113,7 @@ class Driver extends org.apache.calcite.jdbc.Driver { /** * Ensure that the driver will be registered on first instantiation of Driver object. */ - isRegistered.synchronized { + Driver.synchronized { if (!isRegistered) { register() isRegistered = true diff --git a/pom.xml b/pom.xml index e4343fa..a592e5c 100644 --- a/pom.xml +++ b/pom.xml @@ -266,6 +266,7 @@ -nowarn -unchecked -deprecation + -Xexperimental -target:jvm-1.8 1.8