-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build end-to-end prototype with basic functionalities.
- Loading branch information
xwkuang5
committed
Dec 1, 2021
1 parent
7ef52a3
commit f63abbe
Showing
5 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "calcite"] | ||
path = calcite | ||
url = https://github.com/apache/calcite.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
if [[ "$#" -ne 2 ]] | ||
then | ||
echo "Illegal number of parameters." | ||
echo "Usage: /path/to/ledger_sql.sh </path/to/ledger> </path/to/scratch/dir>" | ||
exit | ||
fi | ||
|
||
LEDGER_FILE="$1" | ||
SCRATCH_DIR="$2" | ||
CALCITE_LEDGER_SCHEMA_NAME=LEDGER | ||
CALCITE_LEDGER_SCHEMA_DIR="$SCRATCH_DIR/LEDGER" | ||
|
||
clean_up () { | ||
ARG=$? | ||
rm -rf $SCRATCH_DIR | ||
exit $ARG | ||
} | ||
trap clean_up EXIT | ||
|
||
# Initialize Calcite. | ||
git submodule update --init --recursive | ||
|
||
ROOT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" | ||
|
||
pushd $ROOT_DIR/calcite && ./gradlew -q :example:csv:buildSqllineClasspath && popd >/dev/null 2>&1 | ||
|
||
mkdir -p $SCRATCH_DIR | ||
|
||
# Populate model.json from template | ||
sed "s/<calcite_ledger_schema_name>/$CALCITE_LEDGER_SCHEMA_NAME/g" $ROOT_DIR/model.json > "$SCRATCH_DIR/model.json" | ||
|
||
# Use # as separator in sed instead of / to avoid confusion with / in the path. | ||
sed -i "s#<calcite_ledger_schema_dir>#$CALCITE_LEDGER_SCHEMA_DIR#g" "$SCRATCH_DIR/model.json" | ||
|
||
mkdir -p $CALCITE_LEDGER_SCHEMA_DIR | ||
|
||
# Generate the CSV output of the ledger file. | ||
$ROOT_DIR/txn_gen.sh $LEDGER_FILE $CALCITE_LEDGER_SCHEMA_DIR/LEDGER.csv "$SCRATCH_DIR/scratchfile" | ||
|
||
# Start sqlline. | ||
java \ | ||
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl \ | ||
-jar $ROOT_DIR/calcite/example/csv/build/libs/sqllineClasspath.jar \ | ||
-u jdbc:calcite:model=$SCRATCH_DIR/model.json \ | ||
-n admin \ | ||
-p admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"version": "1.0", | ||
"defaultSchema": "<calcite_ledger_schema_name>", | ||
"schemas": [ | ||
{ | ||
"name": "<calcite_ledger_schema_name>", | ||
"type": "custom", | ||
"factory": "org.apache.calcite.adapter.csv.CsvSchemaFactory", | ||
"operand": { | ||
"directory": "<calcite_ledger_schema_dir>" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters