Files
Alexey MilovidovandClaude Opus 4.6 b80e20b58d Address PR review comments for polyglot integration
- Fix NUL byte in error diagnostic: the transpiled SQL `string_view`
  in the exception message used `sql_query_size` which includes the
  trailing null byte from Rust's `CString`. Use `sql_query_size - 1`.
- Fix grammar in polyglot.h: "which's" -> "whose".
- Add negative test case for invalid `polyglot_dialect` value to cover
  the failure-path diagnostic.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-03-14 09:10:04 +00:00

27 lines
1.0 KiB
C++

#pragma once
#include <cstdint>
extern "C" {
/// Transpiles SQL from a source dialect to ClickHouse SQL.
/// @param query is a pointer to the beginning of the SQL query.
/// @param query_size is the size of the SQL query.
/// @param source_dialect is a pointer to the beginning of the dialect name string (e.g. "sqlite", "mysql").
/// @param source_dialect_size is the size of the dialect name string.
/// @param out is a pointer to a uint8_t pointer which will be set to the beginning of the null terminated transpiled SQL or the error message.
/// @param out_size is the size of the string pointed by `out`.
/// @returns zero in case of success, non-zero in case of failure.
int64_t polyglot_transpile(
const uint8_t * query,
uint64_t query_size,
const uint8_t * source_dialect,
uint64_t source_dialect_size,
uint8_t ** out,
uint64_t * out_size);
/// Frees the passed in pointer whose memory was allocated by Rust allocators previously.
void polyglot_free_pointer(uint8_t * ptr_to_free);
} // extern "C"