mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-31 12:52:13 +00:00
Add schemaless in FE columns API response (#895)
This commit is contained in:
parent
f1fefc9714
commit
031db4f657
@ -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<DatasetColumn> getDatasetColumnsByID(int datasetId, @Nonnull String datasetUrn) {
|
||||
public DatasetSchema getDatasetColumnsByID(int datasetId, @Nonnull String datasetUrn) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("datasetId", datasetId);
|
||||
|
||||
List<DatasetColumn> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<DatasetColumn> columns;
|
||||
}
|
@ -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<DatasetColumn> 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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user