Skip to content

Conversation

@wendigo
Copy link
Contributor

@wendigo wendigo commented Dec 1, 2025

Description

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Dec 1, 2025
@wendigo wendigo requested a review from losipiuk December 1, 2025 12:12
@wendigo wendigo force-pushed the serafin/spooling-checks branch from d33315b to 3c687f5 Compare December 1, 2025 15:35
@wendigo wendigo requested a review from findepi December 1, 2025 15:35
@wendigo wendigo force-pushed the serafin/spooling-checks branch from 3c687f5 to 22f5613 Compare December 1, 2025 15:49
}
}

private static String describeBlock(Block block)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we improve the Block#toString implementations to print this instead ?
It would be beneficial for debugging in general

@Override
public boolean isSupported(Block block)
{
return block instanceof ByteArrayBlock;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return block instanceof ByteArrayBlock;
return block.getUnderlyingValueBlock() instanceof ByteArrayBlock;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least according to actual requirements in encode

Comment on lines +166 to +167
case DictionaryBlock dictionaryBlock -> "DictionaryBlock{%s}".formatted(describeBlock(dictionaryBlock.getDictionary()));
case RunLengthEncodedBlock runLengthEncodedBlock -> "RleBlock{%s}".formatted(runLengthEncodedBlock.getValue());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle via block.getUnderlyingValueBlock()

case ArrayBlock arrayBlock -> "ArrayBlock{%s}".formatted(describeBlock(arrayBlock.getElementsBlock()));
case MapBlock mapBlock -> "MapBlock{keys=%s, values=%s}".formatted(describeBlock(mapBlock.getKeyBlock()), describeBlock(mapBlock.getValueBlock()));
case RowBlock rowBlock -> "RowBlock{fields=%s}".formatted(rowBlock.getFieldBlocks().stream().map(JsonEncodingUtils::describeBlock).collect(joining(", ")));
default -> block.toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should not be here for ever.
Let's file an issue describing problem we're trying to identify and add a TODO comment + link here to eventually remove this boiler-plate.
Also, it would probably be enough to handle primitive types only. Code would be much simpler, while debuggability would be near exact the same.

generator.flush(); // final flush to have the data written to the output stream
}
catch (Exception e) {
throwableConsumer.accept(new TrinoException(SERIALIZATION_ERROR, "Could not serialize data to JSON", e));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is quite a bit complex for a simple debugging log.
Did you consider maybe keeping track of deserialization state (change it as loop progresses) and add it to exception message here. This way you can easily get information like channel name or data types without all those code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants