Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve log message for ORC and table definition mismatch #12783

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/trino-orc/src/main/java/io/trino/orc/OrcReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,13 @@ private static OrcColumn createOrcColumn(
ColumnMetadata<OrcType> types,
OrcDataSourceId orcDataSourceId)
{
String path = fieldName.isEmpty() ? parentStreamName : parentStreamName + "." + fieldName;
String path;
if (fieldName.isEmpty()) {
path = parentStreamName;
}
else {
path = parentStreamName.isEmpty() ? fieldName : parentStreamName + "." + fieldName;
}
OrcType orcType = types.get(columnId);

List<OrcColumn> nestedColumns = ImmutableList.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.function.Predicate;

import static java.lang.Math.max;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;

final class ReaderUtils
Expand All @@ -42,9 +43,9 @@ public static OrcCorruptionException invalidStreamType(OrcColumn column, Type ty
throw new OrcCorruptionException(
column.getOrcDataSourceId(),
"Cannot read SQL type '%s' from ORC stream '%s' of type %s with attributes %s",
type,
type.toString().toUpperCase(ENGLISH),
column.getPath(),
column.getColumnType(),
column.getColumnType().toString().toUpperCase(ENGLISH),
column.getAttributes());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ public void testOrcColumnTypeChange(boolean transactional)
.containsOnly(row(111, "Katy", 57, "CA"), row(222, "Joe", 72, "WA"));
log.info("This shows that Trino gets an exception trying to widen the type");
assertQueryFailure(() -> onTrino().executeQuery("SELECT * FROM " + tableName))
.hasMessageMatching(".*Malformed ORC file. Cannot read SQL type 'integer' from ORC stream '.*.age' of type BYTE with attributes.*");
.hasMessageMatching(".*Malformed ORC file. Cannot read SQL type 'INTEGER' from ORC stream '.*age' of type BYTE with attributes.*");
});
}

Expand Down
Loading