-
Notifications
You must be signed in to change notification settings - Fork 123
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
feat: PostgreSQL dialect databases #1673
Conversation
google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractStructReader.java
Outdated
Show resolved
Hide resolved
import com.google.common.base.Preconditions; | ||
|
||
@InternalApi | ||
public class PostgreSQLStatementParser extends AbstractStatementParser { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woa, hand wrote parser. Nice job, we should also have this kind of parser at the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could re-write the backend to Java and then add this parser :-)
@@ -371,6 +373,8 @@ private Object getAsObject(int columnIndex) { | |||
return getDoubleListInternal(columnIndex); | |||
case NUMERIC: | |||
return getBigDecimalListInternal(columnIndex); | |||
case PG_NUMERIC: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PG does not support Struct, right? So, for now, we will not hit this PG_NUMERIC in Struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PG currently does not support structs in the backend, so in that sense we won't see this coming from the backend. The client library however allows users to convert a row to a struct, and in that case we could encounter it:
java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/ResultSet.java
Line 52 in 8ea2220
Struct getCurrentRowAsStruct(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we did not parameterize some integration tests with the pg dialect. Could you add the parameterization for the ITBatchReadTest?
* Dialect#values()}. | ||
*/ | ||
public @Nullable Dialect getDialect() { | ||
return dialect; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it ever be null? Maybe we can say if null return UNSPECIFIED or GOOGLE_SQL_STANDARD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DatabaseInfo(DatabaseId id, State state)
constructor sets it to null
(and also a lot of other fields that also could have had non-null values, like the encryption config), so I think we should keep it this way to keep it consistent with the other properties in the class.
Thanks for doing this! |
I've parameterized the |
Adds support for Cloud Spanner databases using the PostgreSQL dialect.