Skip to content
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

GEN-1836: Table custom property enhancements #18239

Merged
merged 17 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1518,12 +1518,6 @@ private void validateTableType(JsonNode fieldValue, String propertyConfig, Strin
+ undefinedColumns);
}

if (fieldValue.get("rows").size() > tableConfig.getRowCount()) {
throw new IllegalArgumentException(
"Number of rows should be less than or equal to the expected row count "
+ tableConfig.getRowCount());
}

Set<String> rowFieldNames = new HashSet<>();
fieldValue.get("rows").forEach(row -> row.fieldNames().forEachRemaining(rowFieldNames::add));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static org.openmetadata.service.util.EntityUtil.getCustomField;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -243,12 +242,6 @@ private void validateTableTypeConfig(CustomPropertyConfig config) {
JsonNode configNode = JsonUtils.valueToTree(config.getConfig());
TableConfig tableConfig = JsonUtils.convertValue(config.getConfig(), TableConfig.class);

// rowCount is optional, if not present set it to the default value
if (!configNode.has("rowCount")) {
((ObjectNode) configNode).put("rowCount", tableConfig.getRowCount());
config.setConfig(configNode);
}

List<String> columns = new ArrayList<>();
configNode.path("columns").forEach(node -> columns.add(node.asText()));
Set<String> uniqueColumns = new HashSet<>(columns);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,26 +342,6 @@ void put_patch_customProperty_table_200() throws IOException {
+ " and "
+ tableConfig.getMaxColumns());

tableTypeFieldA.setCustomPropertyConfig(
new CustomPropertyConfig()
.withConfig(
new TableConfig()
.withColumns(Set.of("column-1", "column-2", "column-3"))
.withRowCount(200)));
ChangeDescription change2 = getChangeDescription(databaseEntity, MINOR_UPDATE);
Type databaseEntity2 = databaseEntity;
assertResponseContains(
() ->
addCustomPropertyAndCheck(
databaseEntity2.getId(),
tableTypeFieldA,
ADMIN_AUTH_HEADERS,
MINOR_UPDATE,
change2),
Status.BAD_REQUEST,
"Custom Property table has invalid value rowCount must be less than or equal to "
+ tableConfig.getMaxRows());

ObjectMapper mapper = new ObjectMapper();
ObjectNode tableConfigJson = mapper.createObjectNode();
ArrayNode columnsArray = tableConfigJson.putArray("columns");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@
"type": "string",
"description": "The cell value of each column in the row."
}
},
"minItems": 1,
"maxItems": 10
}
}
},
"required": ["columns"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
"maxItems": 3,
"uniqueItems": true
},
"rowCount": {
"type": "integer",
"default": 10,
"description": "Number of rows. Defaults to maxRows if not explicitly set.",
"minimum": 1,
"maximum": 10
},
"minColumns": {
"type": "integer",
"default": 1,
Expand All @@ -33,16 +26,6 @@
"type": "integer",
"default": 3,
"$comment": "For internal use only: Maximum number of columns."
},
"minRows": {
"type": "integer",
"default": 1,
"$comment": "For internal use only: Minimum number of rows."
},
"maxRows": {
"type": "integer",
"default": 10,
"$comment": "For internal use only: Maximum number of rows."
}
},
"required": ["columns"],
Expand Down
Loading
Loading