diff --git a/wherehows-dao/src/main/java/wherehows/dao/view/DatasetViewDao.java b/wherehows-dao/src/main/java/wherehows/dao/view/DatasetViewDao.java index 981ad78fd0..562d6c7dd4 100644 --- a/wherehows-dao/src/main/java/wherehows/dao/view/DatasetViewDao.java +++ b/wherehows-dao/src/main/java/wherehows/dao/view/DatasetViewDao.java @@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j; import wherehows.dao.table.DictDatasetDao; import wherehows.models.table.DictDataset; import wherehows.models.view.DatasetColumn; +import wherehows.models.view.DatasetSchema; import wherehows.models.view.DatasetView; import static org.apache.commons.lang3.StringUtils.isNotBlank; @@ -99,13 +100,18 @@ public class DatasetViewDao extends BaseViewDao { * @param datasetUrn String * @return List of DatasetColumn */ - public List getDatasetColumnsByID(int datasetId, @Nonnull String datasetUrn) { + public DatasetSchema getDatasetColumnsByID(int datasetId, @Nonnull String datasetUrn) { Map params = new HashMap<>(); params.put("datasetId", datasetId); List columns = getEntityListBy(GET_DATASET_COLUMNS_BY_DATASET_ID, DatasetColumn.class, params); fillInColumnEntity(columns); - return columns; + + DatasetSchema schema = new DatasetSchema(); + schema.setSchemaless(false); + schema.setColumns(columns); + + return schema; } /** diff --git a/wherehows-dao/src/main/java/wherehows/models/view/DatasetSchema.java b/wherehows-dao/src/main/java/wherehows/models/view/DatasetSchema.java new file mode 100644 index 0000000000..03e2906f97 --- /dev/null +++ b/wherehows-dao/src/main/java/wherehows/models/view/DatasetSchema.java @@ -0,0 +1,30 @@ +/** + * Copyright 2015 LinkedIn Corp. All rights reserved. + * + * Licensed 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. + */ +package wherehows.models.view; + +import java.util.List; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + + +@Setter +@Getter +@NoArgsConstructor +public class DatasetSchema { + + private Boolean schemaless; + + private List columns; +} diff --git a/wherehows-frontend/app/controllers/api/v1/Dataset.java b/wherehows-frontend/app/controllers/api/v1/Dataset.java index c26ab1c4b4..85de5871e1 100644 --- a/wherehows-frontend/app/controllers/api/v1/Dataset.java +++ b/wherehows-frontend/app/controllers/api/v1/Dataset.java @@ -42,6 +42,7 @@ import wherehows.models.table.ImpactDataset; import wherehows.models.view.DatasetColumn; import wherehows.models.view.DatasetCompliance; import wherehows.models.view.DatasetOwner; +import wherehows.models.view.DatasetSchema; import wherehows.models.view.DatasetView; import wherehows.models.view.DsComplianceSuggestion; @@ -242,13 +243,14 @@ public class Dataset extends Controller { public static Result getDatasetColumnsByID(int id) { String urn = getDatasetUrnByIdOrCache(id); - List columns = DATASET_VIEW_DAO.getDatasetColumnsByID(id, urn); + DatasetSchema schema = DATASET_VIEW_DAO.getDatasetColumnsByID(id, urn); ObjectNode result = Json.newObject(); - if (columns != null && columns.size() > 0) { + if (schema != null) { result.put("status", "ok"); - result.set("columns", Json.toJson(columns)); + result.put("schemaless", schema.getSchemaless()); + result.set("columns", Json.toJson(schema.getColumns())); } else { result.put("status", "error"); result.put("message", "record not found");