Files
greptimedb/src
zhaiAohan 47f6805189 feat: infer remote table schema for relational external tables (#10200)
* feat: infer remote table schema for relational external tables

Signed-off-by: tian1220A <1573612521@qq.com>

* fix: factor complex tuple into type alias to silence clippy

The 6-tuple returned by INFORMATION_SCHEMA.COLUMNS triggers
clippy::type_complexity under -D warnings. Alias it as RawColumnRow so
the driver's FromRow impl for tuples is preserved.

Signed-off-by: tian1220A <1573612521@qq.com>

* refactor: map only selected columns in declared relational external tables

Separate raw remote column metadata fetching from type mapping. The declared form maps only the columns the user lists, while the inferred form maps every remote column.

Signed-off-by: tian1220A <1573612521@qq.com>

* fix: skip DNS resolution for unix-socket MySQL connections

fetch_mysql_columns unconditionally resolved the host via DNS and forced
resolved_ips, which is TCP-only. When the connection DSN carries an explicit
Unix socket (?socket=/path), mysql_async dials the socket path directly, so the
host is a placeholder and an unresolvable hostname should not block the DDL.
Parse the opts first and skip resolution when a socket is configured.

Signed-off-by: tian1220A <1573612521@qq.com>

* fix: use is_none_or to silence clippy::unnecessary_map_or

Signed-off-by: tian1220A <1573612521@qq.com>

* fix: redact relational connection DSNs in debug logs, parser errors and SHOW CREATE TABLE
Signed-off-by: tian1220A <1573612521@qq.com>

* fix: redact sqlparser debug logs leaking connection DSNs

sqlparser logs raw SQL at debug level, which carries the connection DSN
and its password. Wrap the fmt layer with a RedactingFormatter that
redacts DSNs in events whose real target is sqlparser. tracing_log
hard-codes the event target to log, so recover the real target via
NormalizeEvent::normalized_metadata.

Move redact_connection_in_text from table down to common-telemetry so the
logging layer can reuse it; table re-exports it for existing callers.

Signed-off-by: tian1220A <1573612521@qq.com>

* fix: use explicit clone to silence clippy::implicit_clone

Signed-off-by: tian1220A <1573612521@qq.com>

* fix: address review feedback on relational external tables

Reject MySQL TIME, accept a synthetic greptime_timestamp, unify credential redaction via REDACTED_OPTION_VALUE, and add unit tests.

Signed-off-by: tian1220A <1573612521@qq.com>

* fix(telemetry): redact DSN passwords correctly with the url crate

The hand-rolled scanner split username/password at the last colon and treated comma/semicolon/parens as DSN terminators, leaking passwords containing them (e.g. mysql://user:abc:def@host left abc visible). Extract the DSN span and parse it with the url crate, which splits userinfo at the first colon and host at the last @, then rewrite it with the password replaced.

Signed-off-by: tian1220A <1573612521@qq.com>

* refactor: drop generic DSN redaction, keep structured credential redaction

Address review feedback: check table existence before remote schema inference for IF NOT EXISTS; return Option from redact_option_value to avoid redundant allocation.

Signed-off-by: tian1220A <1573612521@qq.com>

---------

Signed-off-by: tian1220A <1573612521@qq.com>
2026-11-18 13:41:19 +00:00
..