Skip to content

Latest commit

 

History

History
 
 

sql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

sql

This folder contains a SQL parser and transpiler based on Apache Calcite.

SQL parser and protobuf builder generation

Please run mvn package in the module to generate the custom SQL parser and protobuf builder classes. You need to have proto compiler installed on the system, here are some resources for installation instructions -

  1. http://google.github.io/proto-lens/installing-protoc.html
  2. https://github.com/protocolbuffers/protobuf#protocol-compiler-installation

Code generation paths -

  • Custom parser will be generated in target/generated-sources/javacc folder
  • Protobuf classes will be generated in target/generated-sources/annotations folder

Dev Note - Please mark target/generated-sources directory as Sources Root if generated code is not recognized by the IDE.

Preliminary notes regarding native build

  • Configs in graalcfg is auto-generated by GraalVM Tracing Agent. In theory, they can be edited manually as Tracing Agent doesn't delete entries (it's append only mode).
  • com.rilldata.RegisterAtRuntime is based on substrait-java (see https://github.com/substrait-io/substrait-java) and their experience compiling Apache Calcite to a native-executable.

Native library build process

  1. Download GraalVM (https://www.graalvm.org/downloads/)

  2. Install native-image:

    gu install native-image

  3. Execute maven profile:

    mvn package -Pnative-lib

Native executable buid process

(Executable can be useful for testing without Go Runtime.)

mvn package -Pnative-executable

Try to run the executable:

./target/sql "select 1"

Running Tracing Agent

See https://www.graalvm.org/22.0/reference-manual/native-image/Agent/ In short, Tracing Agent produces configs in graalcfg that tells native-image compiler which classes/resources will be loaded/created during runtime. Tracing Agent requires the Java bytecode be run in JVM.

./run-agent.sh

It can be necessary to run the target application more than once with different inputs to trigger separate execution paths for a better coverage of dynamic accesses. In case native-image compiler will start to complain or native-executable will produce exceptions about unknown classes then Tracing Agent can help to identify new configuration entries and merge them to the existing configuration.

Releasing for macOS on arm64

Github Actions do not currently support arm64 runners and GraalVM does not support cross-compilation from amd64 to arm64. In the future, we may set up a self-hosted runner, but for now, we deal with this problem by releasing directly from a local machine.

The prerequisites for releasing a new version of librillsql from your local are:

  • Must run on an ARM Mac
  • Must run from repo root
  • Must have gsutil (Google Cloud SDK) installed and authenticated
  • Must have upload access to the pkg.rilldata.com bucket

Given the above, you can release by running:

./sql/scripts/release-macos-arm64.sh