Skip to content

Commit

Permalink
[apache#1707] feat(mysql): Support mysql index.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clearvive authored and Clearvive committed Jan 26, 2024
1 parent aa37505 commit b86d424
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions common/src/main/java/com/datastrato/gravitino/json/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.datastrato.gravitino.dto.rel.expressions.FuncExpressionDTO;
import com.datastrato.gravitino.dto.rel.expressions.FunctionArg;
import com.datastrato.gravitino.dto.rel.expressions.LiteralDTO;
import com.datastrato.gravitino.dto.rel.indexes.IndexDTO;
import com.datastrato.gravitino.dto.rel.partitioning.BucketPartitioningDTO;
import com.datastrato.gravitino.dto.rel.partitioning.DayPartitioningDTO;
import com.datastrato.gravitino.dto.rel.partitioning.FunctionPartitioningDTO;
Expand All @@ -23,12 +24,17 @@
import com.datastrato.gravitino.dto.rel.partitioning.RangePartitioningDTO;
import com.datastrato.gravitino.dto.rel.partitioning.TruncatePartitioningDTO;
import com.datastrato.gravitino.dto.rel.partitioning.YearPartitioningDTO;
import com.datastrato.gravitino.dto.rel.partitions.IdentityPartitionDTO;
import com.datastrato.gravitino.dto.rel.partitions.ListPartitionDTO;
import com.datastrato.gravitino.dto.rel.partitions.PartitionDTO;
import com.datastrato.gravitino.dto.rel.partitions.RangePartitionDTO;
import com.datastrato.gravitino.rel.Column;
import com.datastrato.gravitino.rel.TableChange;
import com.datastrato.gravitino.rel.expressions.Expression;
import com.datastrato.gravitino.rel.expressions.distributions.Strategy;
import com.datastrato.gravitino.rel.expressions.sorts.NullOrdering;
import com.datastrato.gravitino.rel.expressions.sorts.SortDirection;
import com.datastrato.gravitino.rel.indexes.Index;
import com.datastrato.gravitino.rel.types.Type;
import com.datastrato.gravitino.rel.types.Types;
import com.fasterxml.jackson.core.JacksonException;
Expand All @@ -54,6 +60,8 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Logger;
Expand Down Expand Up @@ -368,6 +376,29 @@ public static String getString(String property, JsonNode node) {
return convertToString(property, pNode);
}

private static String getStringOrNull(String property, JsonNode node) {
if (!node.has(property) || node.get(property).isNull()) {
return null;
}

return getString(property, node);
}

private static Map<String, String> getStringMapOrNull(String property, JsonNode node) {
if (!node.has(property) || node.get(property).isNull()) {
return null;
}

JsonNode propertiesNode = node.get(property);
Iterator<Map.Entry<String, JsonNode>> fieldsIterator = propertiesNode.fields();
Map<String, String> properties = Maps.newHashMap();
while (fieldsIterator.hasNext()) {
Map.Entry<String, JsonNode> field = fieldsIterator.next();
properties.put(field.getKey(), field.getValue().asText());
}
return properties;
}

private static String convertToString(String property, JsonNode pNode) {
Preconditions.checkArgument(
pNode != null && !pNode.isNull() && pNode.isTextual(),
Expand Down

0 comments on commit b86d424

Please sign in to comment.