forked from MarquezProject/marquez
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix dataset list error (MarquezProject#266)
* update dataset findAll query to use ns name * add exception handling into /datasets endpoint * all fixes required to successfully wire up a DatasetDao test * the unit test * add new Generator methods * rename DataSource::dataSource attribute to DataSource::name and remove DataSource::type attribute * fix uncaught merge errors
- Loading branch information
1 parent
6d3e953
commit 9aeeafa
Showing
16 changed files
with
180 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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,22 @@ | ||
ALTER TABLE datasources ADD COLUMN name VARCHAR(64) NOT NULL; | ||
ALTER TABLE datasources ADD COLUMN connection_url VARCHAR(128) NOT NULL; | ||
ALTER TABLE datasources DROP COLUMN type; | ||
ALTER TABLE datasources DROP COLUMN name; | ||
ALTER TABLE datasources ADD COLUMN name VARCHAR(64) NOT NULL; | ||
ALTER TABLE datasets DROP COLUMN name; | ||
|
||
CREATE TABLE db_table_infos( | ||
uuid UUID PRIMARY KEY, | ||
db_name VARCHAR(64) NOT NULL, | ||
db_schema_name VARCHAR(64) NOT NULL | ||
); | ||
|
||
ALTER TABLE db_table_versions ADD COLUMN db_table_info_uuid UUID | ||
REFERENCES db_table_infos(uuid) NOT NULL; | ||
|
||
ALTER TABLE db_table_versions ADD COLUMN db_table_name VARCHAR(64) NOT NULL; | ||
|
||
ALTER TABLE db_table_versions ALTER COLUMN description DROP NOT NULL; | ||
|
||
ALTER TABLE datasets DROP COLUMN current_version; | ||
ALTER TABLE datasets ADD COLUMN current_version_uuid UUID; |
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,56 @@ | ||
package marquez.db; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import marquez.common.models.NamespaceName; | ||
import marquez.db.models.DataSourceRow; | ||
import marquez.db.models.DatasetRow; | ||
import marquez.db.models.DbTableInfoRow; | ||
import marquez.db.models.DbTableVersionRow; | ||
import marquez.service.models.Generator; | ||
import org.jdbi.v3.core.Jdbi; | ||
import org.jdbi.v3.sqlobject.SqlObjectPlugin; | ||
import org.jdbi.v3.testing.JdbiRule; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class DatasetDaoTest { | ||
static final Logger logger = LoggerFactory.getLogger(DatasetDaoTest.class); | ||
private DatasetDao datasetDAO; | ||
private marquez.service.models.Namespace namespace = Generator.genNamespace(); | ||
private NamespaceDao namespaceDAO; | ||
|
||
@Rule | ||
public final JdbiRule dbRule = | ||
JdbiRule.embeddedPostgres().withPlugin(new SqlObjectPlugin()).migrateWithFlyway(); | ||
|
||
@Before | ||
public void setup() { | ||
Jdbi jdbi = dbRule.getJdbi(); | ||
datasetDAO = jdbi.onDemand(DatasetDao.class); | ||
namespaceDAO = jdbi.onDemand(NamespaceDao.class); | ||
namespaceDAO.insert(namespace); | ||
} | ||
|
||
private void insertRandomDataset() { | ||
DataSourceRow dataSourceRow = Generator.genDataSourceRow(); | ||
DatasetRow datasetRow = Generator.genDatasetRow(namespace.getGuid(), dataSourceRow.getUuid()); | ||
DbTableInfoRow dbTableInfoRow = Generator.genDbTableInfowRow(); | ||
DbTableVersionRow dbTableVersionRow = | ||
Generator.genDbTableVersionRow(datasetRow.getUuid(), dbTableInfoRow.getUuid()); | ||
datasetDAO.insertAll(dataSourceRow, datasetRow, dbTableInfoRow, dbTableVersionRow); | ||
} | ||
|
||
@Test | ||
public void testFindAll() throws Exception { | ||
assertEquals( | ||
0, datasetDAO.findAll(NamespaceName.fromString(namespace.getName()), 10, 0).size()); | ||
insertRandomDataset(); | ||
insertRandomDataset(); | ||
assertEquals( | ||
2, datasetDAO.findAll(NamespaceName.fromString(namespace.getName()), 10, 0).size()); | ||
} | ||
} |
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
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