Support sheet table function for google sheets connector#15829
Support sheet table function for google sheets connector#15829findepi merged 5 commits intotrinodb:masterfrom
Conversation
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSplit.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSplitManager.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsTableHandle.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSplit.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSplitManager.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/ptf/Query.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/SheetsQueryRunner.java
Outdated
Show resolved
Hide resolved
c22f047 to
caa428b
Compare
42170f1 to
29aee06
Compare
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
80ee121 to
c776428
Compare
|
Ready for another review. |
679472e to
ffa0595
Compare
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
...no-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsConnectorTableHandle.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestGoogleSheets.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsMetadata.java
Outdated
Show resolved
Hide resolved
ffa0595 to
f8fa4a4
Compare
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsConnector.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
.../trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsConnectorFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/ptf/Sheet.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/SheetsQueryRunner.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestGoogleSheets.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestGoogleSheets.java
Outdated
Show resolved
Hide resolved
...no-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsConnectorTableHandle.java
Outdated
Show resolved
Hide resolved
7e968a4 to
d8abfb7
Compare
66b0c3a to
abcd515
Compare
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/ptf/Sheet.java
Outdated
Show resolved
Hide resolved
a3a921f to
12e3d4e
Compare
|
Could you confirm and fix the commit boundaries? |
12e3d4e to
2cafc75
Compare
Removed |
There was a problem hiding this comment.
Engine is responsible for serializing the handles, but i don't think it cares about their common interfaces.
Thus i think we can separate SheetsConnectorTableHandle serialization and ignore (not test) whether jsonCodec(SheetsConnectorTableHandle) is able to find the subclasses.
There was a problem hiding this comment.
I just confirmed, you are correct this bit is not necessary.
Will remove and just test that the specific table handles can be serialized/deserialized.
There was a problem hiding this comment.
cast of expected is redundant. why not just declare the variable with a more specific type
There was a problem hiding this comment.
Removed after the above refactor.
There was a problem hiding this comment.
how does googleSheetIdHere typically look like? are they numeric, alphanumeric?
There was a problem hiding this comment.
See TestSheetsPlugin for an example sheet id. For example: 1S625j2oTptRepg6Yci68fCYE1269tdoSjljNOmTgQ3U
There was a problem hiding this comment.
Following the Mozilla SQL style ideally .. in this case I would confirmhow we format in all other docs .. but I think this is right
There was a problem hiding this comment.
I copied this formatting from the other table function docs, example: https://github.com/trinodb/trino/blob/master/docs/src/main/sphinx/connector/mongodb.rst#table-functions
There was a problem hiding this comment.
is this formatting compatible with how Trino SQL formatter would format this?
There was a problem hiding this comment.
Did this in a debugger:
var statement = new SqlParser().createStatement("SELECT * FROM TABLE(example.system.sheet(id => 'googleSheetIdHere', range => 'TabName!A1:B4'))", new ParsingOptions());
SqlFormatter.formatSql(statement);
The formatter decides to write the query like this:
SELECT *
FROM
TABLE(example.system.sheet(
id => 'googleSheetIdHere',
range => 'TabName!A1:B4'))
I did not know that formatter existed, good to know. Changed.
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
.../trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsSheetTableHandle.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/test/java/io/trino/plugin/google/sheets/TestGoogleSheets.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
How long does it take to run this test class?
There was a problem hiding this comment.
pretty fast, ~15 seconds on my local machine. most of which is creating the catalog.
There was a problem hiding this comment.
what about adding a test case in TestSheetsPlugin (instead?)
There was a problem hiding this comment.
I do not think that helps, TestSheetsPlugin runs in 1-2 seconds currently.
Moving the test case in there will just make TestSheetsPlugin take ~15 seconds instead of ~1-2 seconds. I need to not just verify the connector can startup without the metadata sheet id, but also that the connector can run a table function query successfully without a metadata id.
There was a problem hiding this comment.
@grantatspothero i understand the approach currently taken is best from test coverage perspective.
@nineinchnick and I were recently debating our inherently limited ability to have test coverage, and how much we can test in total on the CI. Looks like there are and will always be limits to that. This made me more cautious about time being added to tests with respect to additional confidence gained when doing so. Ultimately, we need to accept the fact we cannot test everything, which is especially sad to me.
(no change requested here, but I'd still consider not having this test class)
There was a problem hiding this comment.
Need to mention that this is the example catalog..
2cafc75 to
154492a
Compare
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-google-sheets/src/main/java/io/trino/plugin/google/sheets/SheetsClient.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
The error codes for: SHEETS_UNKNOWN_TABLE_ERROR and NOT_FOUND respectively. changed the comment to use the names instead of the codes to be clearer.
d0309f3 to
61c8c5b
Compare
findepi
left a comment
There was a problem hiding this comment.
LGTM
thanks @grantatspothero for quick response loop
There was a problem hiding this comment.
thanks, now i can read the comment at least :)
however, i don't understand why we would want to throw "not found" within IOException catch block
to me, the current SHEETS_UNKNOWN_TABLE_ERROR looks fine (the IOException is just some error)
if we want to detect that IOException conveys "specific sheet doesn't exist", we could do that (but we wouldnt' say TableNotFound even then, because the requested sheet may not be a table)
if it was up to me to decide, and if no new information is provided to me, i would just delete this TODO comment and worry about that later, and only if we learn later there is something to worry about
with the sheet table function, the metadata sheet is not longer required.
Provide human readable error message instead of: 'InvalidCacheLoadException: CacheLoader returned null for key'
61c8c5b to
d3ed6c2
Compare
|
(rebased to resolve conflict) |
|
/test-with-secrets sha=d3ed6c25f1b3add9cdd97d9590780e24ecc3a38d |
|
CI green. Waiting for secrets run to finish. |
|
Could not find the secret run here: https://github.com/trinodb/trino/actions?query=event%3Arepository_dispatch I see other secrets runs from other PRs, but not for the commit |
|
@grantatspothero thanks for reminding me we don't need a run with secrets for this PR |
Description
Supports
sheettable function for the google sheets connector.Allows querying google sheets directly by id instead of requiring a metadata sheet mapping.
Also makes the
gsheets.metadata-sheet-idconfig optional since the sheet table function makes it no longer strictly required.Additional context and related issues
N/A
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text: