-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
INSERT/REPLACE dimension target column types are validated against source input expressions #15962
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
acfa4ca
* address remaining comments from https://github.com/apache/druid/pul…
zachjsh e6c3b3b
Merge remote-tracking branch 'apache/master' into validate-target-col…
zachjsh d30a729
* address remaining comments from https://github.com/apache/druid/pu…
zachjsh 4947aba
* add test that exposes relational algebra issue
zachjsh 50bef96
* simplify test exposing issue
zachjsh 23c6173
* fix
zachjsh f58a417
Merge remote-tracking branch 'apache/master' into validate-target-col…
zachjsh 841dba5
* add tests for sealed / non-sealed
zachjsh d771bdb
* update test descriptions
zachjsh cd4bfa9
* fix test failure when -Ddruid.generic.useDefaultValueForNull=true
zachjsh 2d3e86e
* check type assignment based on natice Druid types
zachjsh 651ad56
* add tests that cover missing jacoco coverage
zachjsh 1460bea
* add replace tests
zachjsh ddf8189
Merge remote-tracking branch 'apache/master' into validate-target-col…
zachjsh f85c21a
* add more tests and comments about column ordering
zachjsh 7544ac9
* simplify tests
zachjsh 162bd09
* review comments
zachjsh 55b3e90
* remove commented line
zachjsh bb5b8c0
Merge remote-tracking branch 'apache/master' into validate-target-col…
zachjsh a89b4a3
* STRING family types should be validated as non-null
zachjsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
173 changes: 0 additions & 173 deletions
173
...s-core/druid-catalog/src/test/java/org/apache/druid/catalog/sql/CatalogIngestionTest.java
This file was deleted.
Oops, something went wrong.
114 changes: 114 additions & 0 deletions
114
...ions-core/druid-catalog/src/test/java/org/apache/druid/catalog/sql/CatalogInsertTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.catalog.sql; | ||
|
||
import org.apache.druid.catalog.CatalogException; | ||
import org.apache.druid.catalog.model.TableMetadata; | ||
import org.apache.druid.catalog.model.facade.DatasourceFacade; | ||
import org.apache.druid.catalog.model.table.ClusterKeySpec; | ||
import org.apache.druid.catalog.model.table.TableBuilder; | ||
import org.apache.druid.catalog.storage.CatalogStorage; | ||
import org.apache.druid.catalog.storage.CatalogTests; | ||
import org.apache.druid.catalog.sync.CachedMetadataCatalog; | ||
import org.apache.druid.catalog.sync.MetadataCatalog; | ||
import org.apache.druid.metadata.TestDerbyConnector.DerbyConnectorRule5; | ||
import org.apache.druid.sql.calcite.CalciteCatalogInsertTest; | ||
import org.apache.druid.sql.calcite.planner.CatalogResolver; | ||
import org.apache.druid.sql.calcite.table.DatasourceTable; | ||
import org.apache.druid.sql.calcite.util.SqlTestFramework; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* Test the use of catalog specs to drive MSQ ingestion. | ||
*/ | ||
public class CatalogInsertTest extends CalciteCatalogInsertTest | ||
{ | ||
@RegisterExtension | ||
public static final DerbyConnectorRule5 DERBY_CONNECTION_RULE = new DerbyConnectorRule5(); | ||
|
||
private static CatalogStorage storage; | ||
|
||
@Override | ||
public CatalogResolver createCatalogResolver() | ||
{ | ||
CatalogTests.DbFixture dbFixture = new CatalogTests.DbFixture(DERBY_CONNECTION_RULE); | ||
storage = dbFixture.storage; | ||
MetadataCatalog catalog = new CachedMetadataCatalog( | ||
storage, | ||
storage.schemaRegistry(), | ||
storage.jsonMapper() | ||
); | ||
return new LiveCatalogResolver(catalog); | ||
} | ||
|
||
@Override | ||
public void finalizeTestFramework(SqlTestFramework sqlTestFramework) | ||
{ | ||
super.finalizeTestFramework(sqlTestFramework); | ||
buildDatasources(); | ||
} | ||
|
||
public void buildDatasources() | ||
{ | ||
resolvedTables.forEach((datasourceName, datasourceTable) -> { | ||
DatasourceFacade catalogMetadata = ((DatasourceTable) datasourceTable).effectiveMetadata().catalogMetadata(); | ||
TableBuilder tableBuilder = TableBuilder.datasource(datasourceName, catalogMetadata.segmentGranularityString()); | ||
catalogMetadata.columnFacades().forEach( | ||
columnFacade -> { | ||
tableBuilder.column(columnFacade.spec().name(), columnFacade.spec().dataType()); | ||
} | ||
); | ||
|
||
if (catalogMetadata.hiddenColumns() != null && !catalogMetadata.hiddenColumns().isEmpty()) { | ||
tableBuilder.hiddenColumns(catalogMetadata.hiddenColumns()); | ||
} | ||
|
||
if (catalogMetadata.isSealed()) { | ||
tableBuilder.sealed(true); | ||
} | ||
|
||
if (catalogMetadata.clusterKeys() != null && !catalogMetadata.clusterKeys().isEmpty()) { | ||
tableBuilder.clusterColumns(catalogMetadata.clusterKeys().toArray(new ClusterKeySpec[0])); | ||
} | ||
|
||
createTableMetadata(tableBuilder.build()); | ||
}); | ||
DatasourceFacade catalogMetadata = | ||
((DatasourceTable) resolvedTables.get("foo")).effectiveMetadata().catalogMetadata(); | ||
TableBuilder tableBuilder = TableBuilder.datasource("foo", catalogMetadata.segmentGranularityString()); | ||
catalogMetadata.columnFacades().forEach( | ||
columnFacade -> { | ||
tableBuilder.column(columnFacade.spec().name(), columnFacade.spec().dataType()); | ||
} | ||
); | ||
} | ||
|
||
private void createTableMetadata(TableMetadata table) | ||
{ | ||
try { | ||
storage.tables().create(table); | ||
} | ||
catch (CatalogException e) { | ||
fail(e.getMessage()); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
there are a lots of duplication with
CatalogInsertTest
andCatalogReplaceTest
(4 lines differ)and also
CatalogQueryTest
is pretty similar - seems like it has a different method order...could you put all these into some common place (a rule?) and reuse that everywhere?