Skip to content
Merged
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
10 changes: 9 additions & 1 deletion .github/workflows/job-arrow-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ jobs:
run: |
brew install llvm
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> "$GITHUB_ENV"
# Pin the clang executable to the one shipped with the same llvm as
# libclang. Otherwise clang-sys (used by ext-php-rs's bindgen) falls
# back to `xcodebuild -find clang` and mixes Xcode's clang headers
# (e.g. arm_neon.h) with brew's newer libclang, which fails to compile.
echo "CLANG_PATH=$(brew --prefix llvm)/bin/clang" >> "$GITHUB_ENV"

- name: Set LIBCLANG_PATH (Ubuntu)
if: runner.os == 'Linux'
Expand Down Expand Up @@ -147,6 +152,9 @@ jobs:
run: |
brew install autoconf automake libtool llvm
echo "LIBCLANG_PATH=$(brew --prefix llvm)/lib" >> "$GITHUB_ENV"
# See the build job: keep clang and libclang from the same llvm so
# bindgen does not mix brew's libclang with Xcode's clang headers.
echo "CLANG_PATH=$(brew --prefix llvm)/bin/clang" >> "$GITHUB_ENV"

- name: Set LIBCLANG_PATH (Ubuntu)
if: runner.os == 'Linux'
Expand Down Expand Up @@ -180,7 +188,7 @@ jobs:
run: |
sudo pie repository:remove packagist.org
sudo pie repository:add path ${{ github.workspace }}/src/extension/arrow-ext
sudo env "PATH=$PATH" "LIBCLANG_PATH=$LIBCLANG_PATH" "RUSTUP_TOOLCHAIN=$RUSTUP_TOOLCHAIN" "CARGO_HOME=$CARGO_HOME" "RUSTUP_HOME=$RUSTUP_HOME" pie install flow-php/arrow-ext:0.0.9999@dev
sudo env "PATH=$PATH" "LIBCLANG_PATH=$LIBCLANG_PATH" ${CLANG_PATH:+"CLANG_PATH=$CLANG_PATH"} "RUSTUP_TOOLCHAIN=$RUSTUP_TOOLCHAIN" "CARGO_HOME=$CARGO_HOME" "RUSTUP_HOME=$RUSTUP_HOME" pie install flow-php/arrow-ext:0.0.9999@dev

- name: Verify extension is loaded
run: |
Expand Down
8 changes: 4 additions & 4 deletions documentation/contributing/c.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ nix-shell --arg with-pg-query-ext false --arg with-c true --run "cd src/extensio
The extension is only half of the story. A given `libpg_query` version pins a specific PostgreSQL
**grammar**, and that grammar is shared across three places that must always agree:

| Place | What it is | Used by |
|-------|------------|---------|
| `src/extension/pg-query-ext/vendor/libpg_query` (Makefile `PG_VERSION`) | the C library compiled into the extension | CI (`pie` build) |
| `.nix/pkgs/php-pg-query-ext/package.nix` (`libpg_query` `version`/`rev`/`hash`) | the C library compiled into the **nix dev shell** | local `nix-shell` |
| Place | What it is | Used by |
|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|-----------------------------------|
| `src/extension/pg-query-ext/vendor/libpg_query` (Makefile `PG_VERSION`) | the C library compiled into the extension | CI (`pie` build) |
| `.nix/pkgs/php-pg-query-ext/package.nix` (`libpg_query` `version`/`rev`/`hash`) | the C library compiled into the **nix dev shell** | local `nix-shell` |
| `src/lib/postgresql/resources/proto/pg_query.proto` + the generated stubs in `src/lib/postgresql/src/Flow/PostgreSql/Protobuf/` | the protobuf schema the PHP side serializes/deserializes parse trees with | the `flow-php/postgresql` library |

The PHP library round-trips parse trees as protobuf (`pg_query_parse_protobuf` → mutate → `pg_query_deparse`).
Expand Down
2 changes: 1 addition & 1 deletion documentation/contributing/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[TOC]

This document describes how to develop the `arrow-ext` PHP extension, which is written in Rust
using the [ext-php-rs](https://github.com/nicedragons/ext-php-rs) framework.
using the [ext-php-rs](https://github.com/extphprs/ext-php-rs) framework.

## Overview

Expand Down
85 changes: 49 additions & 36 deletions src/extension/arrow-ext/Cargo.lock

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

2 changes: 1 addition & 1 deletion src/extension/arrow-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ crate-type = ["cdylib"]

[dependencies]
ext-php-rs = "0.15"
parquet = { version = "58", default-features = false, features = ["arrow", "arrow_canonical_extension_types", "snap", "flate2", "flate2-zlib-rs", "zstd", "lz4", "brotli"] }
parquet = { version = "58", default-features = false, features = ["arrow", "arrow_canonical_extension_types", "snap", "flate2", "flate2-zlib-rs", "zstd", "lz4", "brotli", "simdutf8"] }
arrow-array = "58"
arrow-buffer = "58"
arrow-schema = { version = "58", features = ["canonical_extension_types"] }
Expand Down
9 changes: 7 additions & 2 deletions src/extension/arrow-ext/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ fn main() {

println!("cargo:rustc-env=ARROW_VERSION={version}");

let arrow_version = resolve_dep_version("arrow-schema").unwrap_or_else(|| "unknown".to_string());
let arrow_version =
resolve_dep_version("arrow-schema").unwrap_or_else(|| "unknown".to_string());
let parquet_version = resolve_dep_version("parquet").unwrap_or_else(|| "unknown".to_string());

println!("cargo:rustc-env=ARROW_LIB_VERSION={arrow_version}");
Expand All @@ -32,7 +33,11 @@ fn resolve_dep_version(crate_name: &str) -> Option<String> {
for line in chunk.lines() {
let line = line.trim();
if line.starts_with("version = ") {
return Some(line.trim_start_matches("version = ").trim_matches('"').to_string());
return Some(
line.trim_start_matches("version = ")
.trim_matches('"')
.to_string(),
);
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/extension/arrow-ext/examples/generate_fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn generate_all_flat_types() {
let col_uint32 = UInt32Array::from(vec![Some(0u32), Some(4294967295u32), None]);
let col_uint64 = UInt64Array::from(vec![Some(0u64), Some(u64::MAX), None]);
let col_float = Float32Array::from(vec![Some(1.5f32), Some(-2.5f32), None]);
let col_double = Float64Array::from(vec![Some(3.14159f64), Some(-2.71828f64), None]);
let col_double = Float64Array::from(vec![Some(1.23456f64), Some(-7.89012f64), None]);
let col_string = StringArray::from(vec![Some("hello"), Some("world"), None]);

let col_binary: BinaryArray = vec![
Expand Down Expand Up @@ -317,10 +317,7 @@ fn generate_deeply_nested() {
let scores_builder = ListBuilder::new(Int64Builder::new());
let struct_builder = StructBuilder::new(
struct_fields,
vec![
Box::new(StringBuilder::new()),
Box::new(scores_builder),
],
vec![Box::new(StringBuilder::new()), Box::new(scores_builder)],
);
let mut groups_builder = ListBuilder::new(struct_builder);

Expand Down
4 changes: 4 additions & 0 deletions src/extension/arrow-ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub extern "C" fn php_module_info(_module: *mut ModuleEntry) {
info_table_end!();
}

/// # Safety
///
/// Invoked by the PHP/Zend engine during module startup. Must only be called by
/// the engine through the registered startup hook, never directly.
pub unsafe extern "C" fn module_startup(_type: i32, _module_number: i32) -> i32 {
if let Err(e) = stream::output_stream::register() {
eprintln!("arrow: failed to register Flow\\Arrow\\OutputStream: {e}");
Expand Down
3 changes: 1 addition & 2 deletions src/extension/arrow-ext/src/parquet/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ pub fn register() -> Result<()> {
}

fn parquet_exception_ce() -> &'static ClassEntry {
ClassEntry::try_find("Flow\\Arrow\\Parquet\\Exception")
.unwrap_or_else(|| ce::exception())
ClassEntry::try_find("Flow\\Arrow\\Parquet\\Exception").unwrap_or_else(|| ce::exception())
}

pub fn parquet_exception(message: impl Into<String>) -> PhpException {
Expand Down
Loading
Loading