Skip to content

Commit

Permalink
Added query explain feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenstott committed Aug 16, 2024
1 parent 7f44c57 commit f6409e8
Show file tree
Hide file tree
Showing 12 changed files with 566 additions and 166 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ target/
/adapters/hive/hive_data/
/adapters/hive/mariadb_data/
/adapters/hive/beeline.conf/
/adapters/hive/hadoop_data/
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 86 additions & 7 deletions adapters/hive/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,102 @@ services:
volumes:
- ./hive_data:/opt/hive
- ./hadoop_data:/opt/hadoop
- ./hive-site.xml:/opt/hive/conf/hive-site.xml
command: |
bash -c '
set -e
export HADOOP_HOME=/opt/hadoop
export HIVE_HOME=/opt/hive
export PATH=$PATH:/opt/hadoop/bin:/opt/hive/bin
# Create a script to set environment variables
cat << EOF > /tmp/set_env.sh
export HADOOP_HOME=/opt/hadoop
export HIVE_HOME=/opt/hive
export PATH=\$PATH:/opt/hadoop/bin:/opt/hive/bin
EOF
# Source the environment script in .bashrc
echo "source /tmp/set_env.sh" >> ~/.bashrc
# Source the environment script for the current session
source /tmp/set_env.sh
apt-get update && apt-get install -y wget
# ... (previous wget and extraction commands remain the same)
# Download and extract Hive if not already present
if [ ! -f "/opt/hive/bin/hive" ]; then
for i in {1..3}; do
wget -O apache-hive-3.1.3-bin.tar.gz https://archive.apache.org/dist/hive/hive-3.1.3/apache-hive-3.1.3-bin.tar.gz
if tar -tzf apache-hive-3.1.3-bin.tar.gz &> /dev/null; then
break
else
echo "Download corrupted, retrying..."
rm apache-hive-3.1.3-bin.tar.gz
fi
done
tar -xzf apache-hive-3.1.3-bin.tar.gz
# Move everything except the conf directory
mv apache-hive-3.1.3-bin/bin apache-hive-3.1.3-bin/lib apache-hive-3.1.3-bin/scripts /opt/hive/
# Only copy conf files that dont already exist
cp -n apache-hive-3.1.3-bin/conf/* /opt/hive/conf/
rm -rf apache-hive-3.1.3-bin apache-hive-3.1.3-bin.tar.gz
fi
# Ensure Hive lib directory exists
mkdir -p /opt/hive/lib
# Download and extract Hadoop if not already present
if [ ! -f "$HADOOP_HOME/bin/hadoop" ]; then
for i in {1..3}; do
wget -O hadoop-3.3.6.tar.gz https://archive.apache.org/dist/hadoop/common/hadoop-3.3.6/hadoop-3.3.6.tar.gz
if tar -tzf hadoop-3.3.6.tar.gz &> /dev/null; then
break
else
echo "Download corrupted, retrying..."
rm hadoop-3.3.6.tar.gz
fi
done
tar -xzf hadoop-3.3.6.tar.gz
mv hadoop-3.3.6/* $HADOOP_HOME/
rm -rf hadoop-3.3.6 hadoop-3.3.6.tar.gz
fi
# Download MySQL connector if not present
if [ ! -f "/opt/hive/lib/mysql-connector-java.jar" ]; then
wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar -O /opt/hive/lib/mysql-connector-java.jar
fi
# Copy Hadoop JARs to Hive lib
find $HADOOP_HOME -name "*.jar" -exec cp {} /opt/hive/lib/ \;
# Ensure hive-exec-*.jar is present
if [ ! -f "/opt/hive/lib/hive-exec-*.jar" ]; then
echo "hive-exec-*.jar is missing. Hive installation may be incomplete."
exit 1
fi
echo "Waiting for MariaDB to be fully ready..."
sleep 15
sleep 30 # Increased wait time
echo "Running schematool..."
/opt/hive/bin/schematool -dbType mysql -initSchema --verbose
/opt/hive/bin/schematool -dbType mysql -initSchema --verbose || {
echo "Schema initialization failed. Checking for file casing issues..."
if [ -f "/var/lib/mysql/metastore/KEY_CONSTRAINTS.frm" ]; then
mv /var/lib/mysql/metastore/KEY_CONSTRAINTS.frm /var/lib/mysql/metastore/key_constraints.frm
echo "File casing corrected. Retrying schema initialization..."
/opt/hive/bin/schematool -dbType mysql -initSchema --verbose
else
echo "File casing issue not found. Please check the logs for more details."
exit 1
fi
}
echo "Schematool completed. Starting Hive metastore..."
/opt/hive/bin/hive --service metastore
'
environment:
HADOOP_HOME: /opt/hadoop
HIVE_CONF_javax_jdo_option_ConnectionURL: jdbc:mysql://mariadb:3306/metastore
HIVE_CONF_javax_jdo_option_ConnectionDriverName: com.mysql.cj.jdbc.Driver
HIVE_CONF_javax_jdo_option_ConnectionUserName: root
HIVE_CONF_javax_jdo_option_ConnectionPassword: rootpassword
HIVE_HOME: /opt/hive
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/hadoop/bin:/opt/hive/bin
depends_on:
mariadb:
condition: service_healthy
Expand All @@ -59,6 +137,7 @@ services:
"
environment:
HADOOP_HOME: /opt/hadoop
HIVE_HOME: /opt/hive
HIVE_CONF_javax_jdo_option_ConnectionURL: jdbc:mysql://mariadb/metastore
HIVE_CONF_javax_jdo_option_ConnectionDriverName: com.mysql.cj.jdbc.Driver
HIVE_CONF_javax_jdo_option_ConnectionUserName: hive
Expand Down
20 changes: 20 additions & 0 deletions adapters/hive/hive-site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://mariadb:3306/metastore</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>rootpassword</value>
</property>
</configuration>
2 changes: 1 addition & 1 deletion adapters/jdbc/dev.docker-compose.calcite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
build:
context: .
dockerfile_inline: |-
FROM jdbc_connector:latest
FROM meta_connector:latest
COPY ./ /etc/connector
develop:
watch:
Expand Down
Loading

0 comments on commit f6409e8

Please sign in to comment.