Jackie-Jiang commented on code in PR #13296: URL: https://github.com/apache/pinot/pull/13296#discussion_r1727768297
########## pinot-spi/src/main/java/org/apache/pinot/spi/data/SchemaInfo.java: ########## @@ -0,0 +1,69 @@ +/** + * 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.pinot.spi.data; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + + +/** + * This class gives the details of a particular schema and the corresponding column count metrics + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class SchemaInfo { + @JsonProperty("schemaName") + private String _schemaName; + + @JsonProperty("numDimensionFields") + private int _numDimensionFields; + + @JsonProperty("numDateTimeFields") + private int _numDateTimeFields; + + @JsonProperty("numMetricFields") + private int _numMetricFields; + + public String getSchemaName() { + return _schemaName; + } + + public int getNumDimensionFields() { + return _numDimensionFields; + } + + public int getNumDateTimeFields() { + return _numDateTimeFields; + } + + public int getNumMetricFields() { + return _numMetricFields; + } + + @JsonCreator + public SchemaInfo(Schema schema) { Review Comment: This is not the correct creator. Creator should take each individual fields ########## pinot-controller/src/test/java/org/apache/pinot/controller/api/TableViewsTest.java: ########## @@ -161,6 +167,55 @@ public void testHybridTableState(String state) assertEquals(tableView._realtime.size(), DEFAULT_NUM_SERVER_INSTANCES); } + @Test + public void testJsonDeserializationSegmentStatusInfo() Review Comment: Suggest moving them into a separate test `SegmentStatusInfoTest` ########## pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java: ########## @@ -118,6 +121,22 @@ public List<String> listSchemaNames(@Context HttpHeaders headers) { return _pinotHelixResourceManager.getSchemaNames(headers.getHeaderString(DATABASE)); } + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("/schemas/info") + @Authorize(targetType = TargetType.CLUSTER, action = Actions.Cluster.GET_SCHEMA_INFO) + @ApiOperation(value = "List all schemas info with count of field specs", notes = "Lists all schemas with field " + + "count details") + public List<SchemaInfo> getSchemaInfo(@Context HttpHeaders headers) { + List<SchemaInfo> schemasInfo = new ArrayList<>(); + TableCache cache = _pinotHelixResourceManager.getTableCache(); + List<String> schemas = _pinotHelixResourceManager.getSchemaNames(headers.getHeaderString(DATABASE)); + for (String schemaName : schemas) { + schemasInfo.add(new SchemaInfo(cache.getSchema(schemaName))); Review Comment: Cache might not be sync'ed with ZK yet, so `cache.getSchema(schemaName)` can potentially return `null`. We need to handle it properly ########## pinot-spi/src/main/java/org/apache/pinot/spi/data/SchemaInfo.java: ########## @@ -0,0 +1,69 @@ +/** + * 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.pinot.spi.data; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + + +/** + * This class gives the details of a particular schema and the corresponding column count metrics + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class SchemaInfo { + @JsonProperty("schemaName") + private String _schemaName; + + @JsonProperty("numDimensionFields") + private int _numDimensionFields; + + @JsonProperty("numDateTimeFields") + private int _numDateTimeFields; + + @JsonProperty("numMetricFields") + private int _numMetricFields; + + public String getSchemaName() { + return _schemaName; + } + + public int getNumDimensionFields() { + return _numDimensionFields; + } + + public int getNumDateTimeFields() { + return _numDateTimeFields; + } + + public int getNumMetricFields() { + return _numMetricFields; + } + + @JsonCreator + public SchemaInfo(Schema schema) { Review Comment: Let's add a `SchemaInfoTest` to verify the ser-de. A easier way to verify ser-de is to create a `SchemaInfo` object, serialize it then deserialize it back, and compare the deserialized one with the original one -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org