This is an automated email from the ASF dual-hosted git repository.

dengzh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 126e3da49cc HIVE-27670: Failed to build the image locally on Apple 
silicon (#4680) (Zhihua Deng, reviewed by Ayush Saxena, Simhadri Govindappa, 
Zoltan Ratkai)
126e3da49cc is described below

commit 126e3da49ccab22cce376ae8f9af76350ecdcd5c
Author: dengzh <[email protected]>
AuthorDate: Wed Sep 13 12:04:12 2023 +0800

    HIVE-27670: Failed to build the image locally on Apple silicon (#4680) 
(Zhihua Deng, reviewed by Ayush Saxena, Simhadri Govindappa, Zoltan Ratkai)
---
 packaging/src/docker/README.md     | 5 +++++
 packaging/src/docker/build.sh      | 2 +-
 packaging/src/docker/entrypoint.sh | 6 +++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/packaging/src/docker/README.md b/packaging/src/docker/README.md
index e15de253368..c206914ef4d 100644
--- a/packaging/src/docker/README.md
+++ b/packaging/src/docker/README.md
@@ -72,6 +72,11 @@ For a quick start, launch the Metastore with Derby,
         --name metastore apache/hive:${HIVE_VERSION}
   ```
 
+NOTE:
+
+For Hive releases before 4.0, if you want to upgrade the existing external 
Metastore schema to the target version,
+then add "--env SCHEMA_COMMAND=upgradeSchema" to the command.
+
 - HiveServer2
 
 Launch the HiveServer2 with an embedded Metastore,
diff --git a/packaging/src/docker/build.sh b/packaging/src/docker/build.sh
index b5cbce78882..f13e3307f71 100755
--- a/packaging/src/docker/build.sh
+++ b/packaging/src/docker/build.sh
@@ -110,7 +110,7 @@ docker build \
         "$WORK_DIR" \
         -f "$WORK_DIR/Dockerfile" \
         -t "$repo/hive:$HIVE_VERSION" \
-        --build-arg "BUILD_ENV=unarchive"
+        --build-arg "BUILD_ENV=unarchive" \
         --build-arg "HIVE_VERSION=$HIVE_VERSION" \
         --build-arg "HADOOP_VERSION=$HADOOP_VERSION" \
         --build-arg "TEZ_VERSION=$TEZ_VERSION" \
diff --git a/packaging/src/docker/entrypoint.sh 
b/packaging/src/docker/entrypoint.sh
index 8f3c4bc564f..a19b50d8daa 100644
--- a/packaging/src/docker/entrypoint.sh
+++ b/packaging/src/docker/entrypoint.sh
@@ -24,7 +24,11 @@ set -x
 SKIP_SCHEMA_INIT="${IS_RESUME:-false}"
 
 function initialize_hive {
-  $HIVE_HOME/bin/schematool -dbType $DB_DRIVER -initOrUpgradeSchema
+  COMMAND="-initOrUpgradeSchema"
+  if [ "$(echo "$HIVE_VER" | cut -d '.' -f1)" -lt "4" ]; then
+     COMMAND="-${SCHEMA_COMMAND:-initSchema}"
+  fi
+  $HIVE_HOME/bin/schematool -dbType $DB_DRIVER $COMMAND
   if [ $? -eq 0 ]; then
     echo "Initialized schema successfully.."
   else

Reply via email to