14 files changed
+58
-13
No files matched your search
@@ -21,6 +21,13 @@ pub fn build_count_table_sql(database_type: Option<DatabaseType>, schema: Option
|
||||
|
||||
pub fn build_table_data_select_sql(options: TableDataSelectSqlOptions) -> String {
|
||||
let database_type = options.database_type;
|
||||
let schema = if database_type == Some(DatabaseType::Informix)
|
||||
&& options.driver_profile.as_deref().is_some_and(|profile| profile.eq_ignore_ascii_case("gbase8s"))
|
||||
{
|
||||
None
|
||||
} else {
|
||||
options.schema.as_deref()
|
||||
};
|
||||
let limit = options.limit.unwrap_or(100);
|
||||
if database_type == Some(DatabaseType::Neo4j) {
|
||||
return build_neo4j_table_select_sql(&options, limit);
|
||||
@@ -31,17 +38,12 @@ pub fn build_table_data_select_sql(options: TableDataSelectSqlOptions) -> String
|
||||
|
||||
// Doris / StarRocks multi-catalog: prefix the catalog for external-catalog tables.
|
||||
let table = if uses_connection_identifier_quote(database_type, options.identifier_quote.as_deref()) {
|
||||
table_data_qualified_table_name(
|
||||
database_type,
|
||||
options.schema.as_deref(),
|
||||
&options.table_name,
|
||||
options.identifier_quote.as_deref(),
|
||||
)
|
||||
table_data_qualified_table_name(database_type, schema, &options.table_name, options.identifier_quote.as_deref())
|
||||
} else {
|
||||
qualified_table_name_with_catalog(
|
||||
database_type,
|
||||
options.catalog.as_deref(),
|
||||
options.schema.as_deref(),
|
||||
schema,
|
||||
options.database.as_deref(),
|
||||
&options.table_name,
|
||||
)
|
||||
@@ -502,6 +504,7 @@ mod tests {
|
||||
) -> TableDataSelectSqlOptions {
|
||||
TableDataSelectSqlOptions {
|
||||
database_type: Some(database_type),
|
||||
driver_profile: None,
|
||||
identifier_quote: None,
|
||||
schema: None,
|
||||
table_name: table.to_string(),
|
||||
|
||||
@@ -370,6 +370,18 @@ fn builds_table_data_where_and_schema_queries() {
|
||||
}),
|
||||
"SELECT * FROM \"App Schema\".\"ANALYZE\" LIMIT 100;"
|
||||
);
|
||||
assert_eq!(
|
||||
build_table_data_select_sql(TableDataSelectSqlOptions {
|
||||
database_type: Some(DatabaseType::Informix),
|
||||
driver_profile: Some("gbase8s".to_string()),
|
||||
identifier_quote: Some(String::new()),
|
||||
schema: Some("gbasedbt".to_string()),
|
||||
table_name: "connection_smoke".to_string(),
|
||||
limit: Some(100),
|
||||
..Default::default()
|
||||
}),
|
||||
"SELECT FIRST 100 * FROM connection_smoke"
|
||||
);
|
||||
assert_eq!(
|
||||
build_table_data_select_sql(TableDataSelectSqlOptions {
|
||||
database_type: Some(DatabaseType::Informix),
|
||||
|
||||
@@ -22,6 +22,8 @@ pub struct TableDataSelectSqlOptions {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub database_type: Option<DatabaseType>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub driver_profile: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub identifier_quote: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub schema: Option<String>,
|
||||
|
||||
Reference in new issue
Block a user