samarthjain commented on code in PR #13612: URL: https://github.com/apache/druid/pull/13612#discussion_r1067323715
########## server/src/main/java/org/apache/druid/segment/indexing/ReaderUtils.java: ########## @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.druid.segment.indexing; + +import org.apache.druid.data.input.impl.DimensionSchema; +import org.apache.druid.data.input.impl.DimensionsSpec; +import org.apache.druid.data.input.impl.TimestampSpec; +import org.apache.druid.java.util.common.logger.Logger; +import org.apache.druid.java.util.common.parsers.JSONPathFieldSpec; +import org.apache.druid.java.util.common.parsers.JSONPathFieldType; +import org.apache.druid.java.util.common.parsers.JSONPathSpec; +import org.apache.druid.query.aggregation.AggregatorFactory; +import org.apache.druid.segment.transform.Transform; +import org.apache.druid.segment.transform.TransformSpec; + +import javax.annotation.Nullable; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ReaderUtils +{ + private static final Logger LOG = new Logger(ReaderUtils.class); + + private static final Pattern JSON_PATH_PATTERN = Pattern.compile("\\[(.*?)]"); + private static final Pattern BRACKET_NOTATED_CHILD_PATTERN = Pattern.compile("'(.*?)'"); + + public static Set<String> getColumnsRequiredForIngestion( + Set<String> fullInputSchema, + TimestampSpec timestampSpec, + DimensionsSpec dimensionsSpec, + TransformSpec transformSpec, + AggregatorFactory[] aggregators, + @Nullable JSONPathSpec flattenSpec + ) + { + Set<String> fieldsRequired = new HashSet<>(); + + // We need to read timestamp column for Druid timestamp field + fieldsRequired.add(timestampSpec.getTimestampColumn()); Review Comment: Since flattenSpec is applied before timestampspec, do you think the order needs to be changed (I am not 100% sure, TBH)? Maybe worth adding a test where the timestamp column is not a top level field. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
