Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP WRITE support #24

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

HTTP WRITE support #24

wants to merge 1 commit into from

Conversation

lmangani
Copy link

@lmangani lmangani commented Mar 4, 2025

This (humble) PR implements basic write (POST) support for the HTTPFS extension - similarly to the S3 features.

The implementation is intentionally simple, extending existing methods without introducing new dependencies.
The scope can be extended to be generally compatible with Web APIs when it comes to file management.

The current validation uses a very generic and simple backend service handling vanilla GET/POST requests and generally compatible with the ClickHouse url function, with nothing special to it. The demo backend is also deployed in public and open for testing, where the /path is the unique key to set/get data.

--- For backwards compatibility, WRITE support is disabled by default
D SET enable_http_write = 1;

--- COPY to remote servers using FORMAT
D SET enable_http_write = true;
D COPY (SELECT version() as version, 9999 as number) TO 'https://duckserver.glitch.me/.json' (FORMAT JSON);
D SELECT * FROM read_json_auto('https://duckserver.glitch.me/test9999');
┌─────────┬────────┐
│ version │ number │
│ varchar │ int64  │
├─────────┼────────┤
│ v1.1.09999 │
└─────────┴────────┘

--- COPY to remote servers using FORMAT auto-detection via extension
D COPY (SELECT version() as version, 9999 as number) TO 'https://duckserver.glitch.me/test.parquet';
D SELECT * FROM read_parquet('https://duckserver.glitch.me/test.parquet');
┌─────────┬────────┐
│ version │ number │
│ varchar │ int64  │
├─────────┼────────┤
│ v1.2.09999 │
└─────────┴────────┘

D SELECT * FROM parquet_schema('https://duckserver.glitch.me/test.parquet');
┌──────────────────────┬───────────────┬────────────┬─────────────┬───┬────────────────┬───────┬───────────┬──────────┬──────────────┐
│      file_name       │     name      │    type    │ type_length │ … │ converted_type │ scale │ precision │ field_id │ logical_type │
│       varcharvarcharvarcharvarchar   │   │    varchar     │ int64 │   int64   │  int64   │   varchar    │
├──────────────────────┼───────────────┼────────────┼─────────────┼───┼────────────────┼───────┼───────────┼──────────┼──────────────┤
│ https://duckserver…  │ duckdb_schema │            │             │ … │                │       │           │          │              │
│ https://duckserver…  │ version       │ BYTE_ARRAY │             │ … │ UTF8           │       │           │          │              │
│ https://duckserver…  │ number        │ INT32      │             │ … │ INT_32         │       │           │          │              │
├──────────────────────┴───────────────┴────────────┴─────────────┴───┴────────────────┴───────┴───────────┴──────────┴──────────────┤
│ 3 rows                                                                                                        11 columns (9 shown) │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@lmangani lmangani marked this pull request as draft March 4, 2025 17:01
@lmangani
Copy link
Author

lmangani commented Mar 4, 2025

Reopening since this is now a separate extension, hoping for a lower entry barrier and avoiding yet another fork of the extensions such as the caching one, etc. Work is in progress to enable compatibility with other extensions in the ecosystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant