Skip to content

Conversation

@JeremyXin
Copy link
Contributor

Purpose of this pull request

fix #9584

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

@Hisoka-X Hisoka-X changed the title [fix][connector-clickhouse] fix SeaTunnelRow tableId set error. [Fix][Connector-clickhouse] Fix SeaTunnelRow tableId set error Jul 17, 2025
Copy link
Member

Choose a reason for hiding this comment

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

I found our test case not check SeaTunnelRow values and tableId which return by batchFetchRecords. Please add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@nielifeng nielifeng requested a review from Copilot July 21, 2025 03:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes an issue with tableId setting in SeaTunnelRow objects for the ClickHouse connector. The main problem was that the SQL string was being incorrectly used as the tableId instead of the proper table path identifier.

  • Updates the batchFetchRecords method signature to accept a TablePath parameter
  • Modifies all calls to batchFetchRecords to pass the table path for proper tableId setting
  • Adds comprehensive test coverage to verify tableId is correctly set in returned SeaTunnelRow objects

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
ClickhouseProxy.java Updates batchFetchRecords method signature to accept TablePath parameter and use it for tableId instead of SQL string
ClickhouseValueReader.java Updates calls to batchFetchRecords to pass the table path parameter
ClickhouseValueReaderTest.java Updates test mocks and adds new test to verify correct tableId setting behavior
ClickhouseSourceConfig.java Adds server timezone configuration to the builder

public void testBatchFetchRecordsAndTableId() throws Exception {
// mock proxy query response
ClickhouseProxy proxy = Mockito.spy(new ClickhouseProxy(node));
Field requestField = ClickhouseProxy.class.getDeclaredField("clickhouseRequest");
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Using reflection to access private fields makes the test fragile and tightly coupled to implementation details. Consider adding a package-private constructor or setter method to ClickhouseProxy for testing purposes instead of using reflection.

Copilot uses AI. Check for mistakes.
// mock proxy query response
ClickhouseProxy proxy = Mockito.spy(new ClickhouseProxy(node));
Field requestField = ClickhouseProxy.class.getDeclaredField("clickhouseRequest");
requestField.setAccessible(true);
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Setting field accessibility bypasses encapsulation and can cause issues in environments with security managers. This approach is brittle and should be replaced with proper dependency injection or test-friendly constructors.

Copilot uses AI. Check for mistakes.
@corgy-w corgy-w merged commit 01f1caa into apache:dev Jul 22, 2025
8 checks passed
dybyte pushed a commit to dybyte/seatunnel that referenced this pull request Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [connector-clickhoue] SeaTunnelRow tableId set error

3 participants