alamb commented on code in PR #19666:
URL: https://github.com/apache/datafusion/pull/19666#discussion_r2664888264
##########
Cargo.lock:
##########
@@ -1203,29 +1180,6 @@ dependencies = [
"syn 2.0.113",
]
-[[package]]
Review Comment:
rust_decimal has many dependencies it turns out, so removing it results in
quite a few less dependencies in datafusion
##########
datafusion/sqllogictest/src/engines/postgres_engine/mod.rs:
##########
@@ -351,58 +342,66 @@ impl sqllogictest::AsyncDB for Postgres {
}
}
-fn convert_rows(rows: &[Row]) -> Vec<Vec<String>> {
- rows.iter()
+fn convert_rows(types: &[Type], messages: &[SimpleQueryMessage]) ->
Vec<Vec<String>> {
+ messages
+ .iter()
+ .filter_map(|message| match message {
+ SimpleQueryMessage::Row(row) => Some(row),
+ _ => None,
+ })
.map(|row| {
- row.columns()
+ types
.iter()
.enumerate()
- .map(|(idx, column)| cell_to_string(row, column, idx))
+ .map(|(idx, column_type)| cell_to_string(row, column_type,
idx))
.collect::<Vec<String>>()
})
.collect::<Vec<_>>()
}
-macro_rules! make_string {
- ($row:ident, $idx:ident, $t:ty) => {{
- let value: Option<$t> = $row.get($idx);
- match value {
- Some(value) => value.to_string(),
- None => NULL_STR.to_string(),
- }
- }};
- ($row:ident, $idx:ident, $t:ty, $convert:ident) => {{
- let value: Option<$t> = $row.get($idx);
- match value {
- Some(value) => $convert(value).to_string(),
- None => NULL_STR.to_string(),
- }
- }};
-}
-
-fn cell_to_string(row: &Row, column: &Column, idx: usize) -> String {
- match column.type_().clone() {
- Type::CHAR => make_string!(row, idx, i8),
- Type::INT2 => make_string!(row, idx, i16),
- Type::INT4 => make_string!(row, idx, i32),
- Type::INT8 => make_string!(row, idx, i64),
- Type::NUMERIC => make_string!(row, idx, Decimal, decimal_to_str),
- Type::DATE => make_string!(row, idx, NaiveDate),
- Type::TIME => make_string!(row, idx, NaiveTime),
- Type::TIMESTAMP => {
- let value: Option<NaiveDateTime> = row.get(idx);
- value
- .map(|d| format!("{d:?}"))
- .unwrap_or_else(|| "NULL".to_string())
+fn cell_to_string(row: &SimpleQueryRow, column_type: &Type, idx: usize) ->
String {
+ // simple_query returns text values, so we parse by Postgres type to keep
Review Comment:
Left in `unwrap()` so we fail fast in case there is some problem converting
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]