Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions .devcontainer/clang/Dockerfile.clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
FROM debian:bookworm

ENV CMAKE_VERSION=3.31.8
ENV MOLD_VERSION=2.40.4

ARG DEB_REGION=""
ARG https_proxy=""
ARG no_proxy=""

# check if deb region is not empty string. If it is, replace the default debian repository with the one for the region.
RUN if [ "$DEB_REGION" != "" ]; then \
sed -i "s|http://deb.debian.org/debian|http://ftp.${DEB_REGION}.debian.org/debian|g" /etc/apt/sources.list.d/debian.sources; \
fi

RUN apt-get update && \
apt-get install -y \
curl \
tar

RUN arch=$(arch) && \
https_proxy=${https_proxy} \
curl -L -# -o /tmp/cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-${arch}.tar.gz && \
tar -xzvf /tmp/cmake.tar.gz -C /opt && \
ln -s /opt/cmake-$CMAKE_VERSION-linux-${arch}/bin/cmake /usr/local/bin/cmake && \
ln -s /opt/cmake-$CMAKE_VERSION-linux-${arch}/bin/ctest /usr/local/bin/ctest && \
rm /tmp/cmake.tar.gz

RUN apt-get update && apt-get install -y \
sudo \
bash \
vim-tiny \
vim \
sudo \
git \
gdb \
python3 \
python3-pip \
python3-virtualenv \
ssh-client \
ninja-build \
bison \
maven \
net-tools \
telnet \
ssh \
rsync \
openssh-server \
lld \
ccache \
binutils-dev \
make \
automake \
autoconf \
htop \
less \
man \
nodejs \
npm \
bsdextrautils \
locales \
clang-19 \
clang++-19 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-19 100 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-19 100 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN ln -sf /bin/bash /bin/sh

RUN https_proxy=${https_proxy} curl -L -O --output-dir /tmp https://github.com/rui314/mold/releases/download/v$MOLD_VERSION/mold-$MOLD_VERSION-$(arch)-linux.tar.gz
RUN cd /tmp && \
sudo tar -C /usr/local --strip-components=1 -xzf mold-$MOLD_VERSION-$(arch)-linux.tar.gz

# Add mold's ld as the first on the path
env PATH=/usr/local/libexec/mold:$PATH

# License header check tool
RUN https_proxy=${https_proxy} curl -L -# -o /tmp/skywalking-eyes-bin.tgz https://dlcdn.apache.org/skywalking/eyes/0.8.0/skywalking-license-eye-0.8.0-bin.tgz && \
mkdir -p /opt/skywalking-license-eye && \
sudo tar -C /opt/skywalking-license-eye --strip-components=1 -xzf /tmp/skywalking-eyes-bin.tgz

ENV PATH="/opt/skywalking-license-eye/bin/linux:${PATH}"

RUN export arch=$(arch | sed 's/^aarch64$/arm64/; s/^x86_64$/amd64/') && \
export https_proxy=${https_proxy} && \
export filename=go1.25.5.linux-${arch}.tar.gz && \
curl -L -O --output-dir /tmp https://go.dev/dl/${filename} && \
sudo rm -rf /usr/local/bin/go && tar -C /usr/local -xzf /tmp/${filename} && \
rm /tmp/${filename}
ENV PATH="/usr/local/go/bin:${PATH}"

# Set up default python virtualenv, and make it the default on PATH
RUN virtualenv -p python3 /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt && \
rm -f requirements.txt

ARG USERNAME=code
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

USER $USERNAME

# Configure default conan profile to use the mold linker
RUN arch=$(uname -m) && mkdir -p ~/.conan2/profiles && cat > ~/.conan2/profiles/default <<EOF
[settings]
arch=$( [ "$arch" = "aarch64" ] && echo "armv8" || echo "$arch" )
build_type=Release
compiler=clang
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=19
os=Linux

[conf]
tools.build:compiler_executables={"c": "clang", "cpp": "clang++"}
tools.build:exelinkflags=['-fuse-ld=mold', '-Wl,--allow-multiple-definition']
tools.build:sharedlinkflags=['-fuse-ld=mold', '-Wl,--allow-multiple-definition']

EOF

# Generate Locales
RUN sudo sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && \
sudo locale-gen && \
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc && \
echo "export LANG=en_US.UTF-8" >> ~/.bashrc && \
echo "export LANGUAGE=en_US.UTF-8" >> ~/.bashrc


ENV SHELL=/bin/bash

WORKDIR /workspace

ENTRYPOINT ["/bin/bash", "-c"]
44 changes: 44 additions & 0 deletions .devcontainer/clang/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "Bolt Clang Development Container",
"build": {
"dockerfile": "Dockerfile.clang",
"context": "../../.github/runners",
"args": {
"DEB_REGION": "",
"https_proxy": "",
"no_proxy": ""
}
},
"containerEnv": {
"https_proxy": "",
"no_proxy": "",
"SHELL": "/bin/bash"
},
"remoteUser": "code",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [],
// Use 'portsAttributes' to set default properties for specific forwarded ports.
"portsAttributes": {},
// Use 'remoteEnv' to set environment variables that are only available inside the container.
"remoteEnv": {},
// Use 'mounts' to make files or directories from your local machine available inside the container.
"mounts": [
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"source=conan-cache,target=/home/code/.conan2/p",
"source=ccache-cache,target=/home/code/.ccache"
],
"runArgs": [
"--security-opt",
"label=disable"
],
"customizations": {
"vscode": {
"extensions": [
"llvm-vs-code-extensions.vscode-clangd"
]
}
},
// Configure tool-specific properties.
"features": {},
"postCreateCommand": ".devcontainer/post_create_command.sh"
}
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-D OS_MACOSX)
endif()

# Only use compiler-rt when building with Clang on Linux for ARM/AArch64
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND OS_LINUX AND (ARCH_AARCH64 OR ARCH_ARM))
add_compile_options(-rtlib=compiler-rt)
add_link_options(-rtlib=compiler-rt)
endif()

list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake"
"${PROJECT_SOURCE_DIR}/CMake/third-party"
)
Expand Down
47 changes: 25 additions & 22 deletions bolt/duckdb/conversion/tests/DuckParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ using namespace bytedance::bolt::duckdb;

namespace {
std::shared_ptr<const core::IExpr> parseExpr(const std::string& exprString) {
ParseOptions options;
return parseExpr(exprString, options);
duckdb::ParseOptions options;
return duckdb::parseExpr(exprString, options);
}
} // namespace

Expand Down Expand Up @@ -297,30 +297,33 @@ TEST(DuckParserTest, between) {

TEST(DuckParserTest, interval) {
auto parseInterval = [](const std::string& sql) {
auto expr =
std::dynamic_pointer_cast<const core::ConstantExpr>(parseExpr(sql));
BOLT_CHECK_NOT_NULL(expr);

auto value =
INTERVAL_DAY_TIME()->valueToString(expr->value().value<int64_t>());
if (expr->alias()) {
return fmt::format("{} AS {}", value, expr->alias().value());
}

return value;
auto parsed = parseExpr(sql);
return parsed->toString();
};

EXPECT_EQ("0 05:00:00.000", parseInterval("INTERVAL 5 HOURS"));
EXPECT_EQ("0 00:36:00.000", parseInterval("INTERVAL 36 MINUTES"));
EXPECT_EQ("0 00:00:07.000", parseInterval("INTERVAL 7 SECONDS"));
EXPECT_EQ("0 00:00:00.123", parseInterval("INTERVAL 123 MILLISECONDS"));

EXPECT_EQ("0 00:00:12.345", parseInterval("INTERVAL 12345 MILLISECONDS"));
EXPECT_EQ("0 03:25:45.678", parseInterval("INTERVAL 12345678 MILLISECONDS"));
EXPECT_EQ("1 03:48:20.100", parseInterval("INTERVAL 100100100 MILLISECONDS"));
EXPECT_EQ(
"to_hours(cast(trunc(cast(5, DOUBLE)), BIGINT))",
parseInterval("INTERVAL 5 HOURS"));
EXPECT_EQ(
"to_minutes(cast(trunc(cast(36, DOUBLE)), BIGINT))",
parseInterval("INTERVAL 36 MINUTES"));
EXPECT_EQ("to_seconds(cast(7, DOUBLE))", parseInterval("INTERVAL 7 SECONDS"));
EXPECT_EQ(
"to_milliseconds(cast(123, DOUBLE))",
parseInterval("INTERVAL 123 MILLISECONDS"));
EXPECT_EQ(
"to_milliseconds(cast(12345, DOUBLE))",
parseInterval("INTERVAL 12345 MILLISECONDS"));
EXPECT_EQ(
"to_milliseconds(cast(12345678, DOUBLE))",
parseInterval("INTERVAL 12345678 MILLISECONDS"));
EXPECT_EQ(
"to_milliseconds(cast(100100100, DOUBLE))",
parseInterval("INTERVAL 100100100 MILLISECONDS"));

EXPECT_EQ(
"0 00:00:00.011 AS x", parseInterval("INTERVAL 11 MILLISECONDS AS x"));
"to_milliseconds(cast(11, DOUBLE)) AS x",
parseInterval("INTERVAL 11 MILLISECONDS AS x"));
}

TEST(DuckParserTest, cast) {
Expand Down
Loading