Skip to content

[BEAM-2442] BeamSql api surface test#3357

Closed
xumingming wants to merge 3 commits intoapache:DSL_SQLfrom
xumingming:BEAM-2442-api-surface-test
Closed

[BEAM-2442] BeamSql api surface test#3357
xumingming wants to merge 3 commits intoapache:DSL_SQLfrom
xumingming:BEAM-2442-api-surface-test

Conversation

@xumingming
Copy link
Contributor

@xumingming xumingming commented Jun 14, 2017

Summary:

  • The surface api of BeamSql includes the following:
    • BeamSql
    • BeamSqlCli
    • BeamSqlEnv
    • All the classes in package org.apache.beam.dsls.sql.schema
  • Calcite related methods are encapsulated into CalciteUtils(which is not part of surface api) to avoid exposure.
  • Created a new BeamSqlTable interface which abstracts the beam table concept.
  • RelDataType, RelProtoDataType are all removed from surface api, BeamSqlRecordType is the only class which represents the schema of a table.
    • java.sql.Types is used to represent sql type instead of Calcite SqlTypeName.

@xumingming
Copy link
Contributor Author

@xumingmin @lukecwik can you take a look at this one?

This might need to be merged before the other BeamSql PRs, otherwise it might cause a lot of conflict.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 507e045 on xumingming:BEAM-2442-api-surface-test into ** on apache:DSL_SQL**.

Copy link

@mingmxu mingmxu left a comment

Choose a reason for hiding this comment

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

Thanks @xumingming .

Let BeamSql and BeamSqlCli extending BeamSqlEnv may not a good option regarding to BEAM-2446. You may change the the scope of SchemaPlus/BeamQueryPlanner to protected to avoid exposure.

@xumingming
Copy link
Contributor Author

@xumingmin , you are right, Let BeamSql extends BeamSqlEnv is not necessary, have made SchemaPlus and BeamQueryPlanner package level access.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 976bad2 on xumingming:BEAM-2442-api-surface-test into ** on apache:DSL_SQL**.

@lukecwik
Copy link
Member

R: @takidau
-R: @lukecwik

Copy link

@mingmxu mingmxu left a comment

Choose a reason for hiding this comment

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

LGTM

@lukecwik
Copy link
Member

Please add a test like SdkCoreApiSurfaceTest which programmatically verifies that the API surface is clean. This test will catch breakages in the API surface in the future and not require manual review.

@xumingming
Copy link
Contributor Author

There is a BeamSqlApiSurfaceTest.java for this. @lukecwik

@lukecwik
Copy link
Member

Sorry about that, did a quick pass and I missed it.

Copy link
Contributor

@takidau takidau left a comment

Choose a reason for hiding this comment

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

I'd like to have the CalciteUtils method names be a little more indicative of the equivalencies the pairs of maps/methods represent. Added comments as such. Otherwise LGTM. Let me know when those changes are made and I'll be happy to merge.

*/
public class CalciteUtils {
private static final Map<Integer, SqlTypeName> SQL_TYPE_MAPPING = new HashMap<>();
private static final Map<SqlTypeName, Integer> INVERSED_SQL_TYPE_MAPPING = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these names would be more clear if they were named something like JAVA_TO_CALCITE_MAPPING and CALCITE_TO_JAVA_MAPPING.

/**
* Get the corresponding {@code SqlTypeName} for an integer sql type.
*/
public static SqlTypeName getSqlTypeName(int type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

They're both SQL types, though. Maybe call this toCalciteType() and the one below toJavaType?

/**
* Generate {@code BeamSqlRecordType} from {@code RelDataType} which is used to create table.
*/
public static BeamSqlRecordType buildRecordType(RelDataType tableInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

toBeamRecordType and toCalciteRecordType for the one below? It's not immediately clear these two methods are inverses of one another otherwise.

@xumingming xumingming force-pushed the BEAM-2442-api-surface-test branch from 976bad2 to c0c4fd5 Compare June 15, 2017 23:27
@xumingming
Copy link
Contributor Author

Update:

  1. Renamed CalciteUtils methods
  2. Resolved conflict.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling c0c4fd5 on xumingming:BEAM-2442-api-surface-test into ** on apache:DSL_SQL**.

@takidau
Copy link
Contributor

takidau commented Jun 16, 2017

Thanks, merging.

asfgit pushed a commit that referenced this pull request Jun 16, 2017
@takidau
Copy link
Contributor

takidau commented Jun 16, 2017

Merged, feel free to close. Thanks!

@xumingming xumingming closed this Jun 16, 2017
@xumingming xumingming deleted the BEAM-2442-api-surface-test branch June 16, 2017 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants