fix(influxdb): merge compat query series and quote explicit columns

This commit is contained in:
zipg authored and GitHub committed 2026-08-31 12:31:36 +08:00
1 parent d1046d54f9
commit b7d33e375f
4 files changed
+170 -33

No files matched your search

@@ -608,14 +608,21 @@ pub(super) fn build_select_columns(
.collect::<Vec<_>>()
.join(", ");
}
if !matches!(database_type, Some(DatabaseType::Hive | DatabaseType::Kyuubi | DatabaseType::Impala)) {
if !matches!(
database_type,
Some(DatabaseType::Hive | DatabaseType::Kyuubi | DatabaseType::Impala | DatabaseType::InfluxDb)
) {
return "*".to_string();
}
columns
.iter()
.map(|column| {
let ident = quote_table_identifier(database_type, column);
format!("{ident} AS {ident}")
if database_type == Some(DatabaseType::Hive) {
format!("{ident} AS {ident}")
} else {
ident
}
})
.collect::<Vec<_>>()
.join(", ")
@@ -770,6 +777,22 @@ mod tests {
}
}
#[test]
fn influxdb_table_select_quotes_explicit_columns() {
// InfluxQL needs double-quoted identifiers and only permits ORDER BY on
// the time column; explicit column lists must not fall back to "*".
assert_eq!(
build_table_data_select_sql(TableDataSelectSqlOptions {
database_type: Some(DatabaseType::InfluxDb),
database: Some("monitor".to_string()),
table_name: "cpu".to_string(),
columns: vec!["time".to_string(), "host".to_string(), "value".to_string()],
..Default::default()
}),
"SELECT \"time\", \"host\", \"value\" FROM \"cpu\" ORDER BY time DESC LIMIT 100;"
);
}
#[test]
fn databricks_table_select_uses_backtick_identifiers() {
assert_eq!(
+1 -1
View File
@@ -492,7 +492,7 @@ fn builds_table_data_where_and_schema_queries() {
include_row_id: false,
..Default::default()
}),
"SELECT `id` AS `id`, `name` AS `name` FROM `dbx_demo`.`connection_test` ORDER BY 1 LIMIT 2 OFFSET 1;"
"SELECT `id`, `name` FROM `dbx_demo`.`connection_test` ORDER BY 1 LIMIT 2 OFFSET 1;"
);
assert_eq!(
build_table_data_select_sql(TableDataSelectSqlOptions {