Github user KanakaKumar commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2804#discussion_r230801853
--- Diff:
store/sdk/src/main/java/org/apache/carbondata/sdk/file/CarbonSchemaReader.java
---
@@ -61,14 +65,121 @@ public static Schema readSchemaInSchemaFile(String
schemaFilePath) throws IOExce
return new Schema(schemaList);
}
+ /**
+ * get carbondata/carbonindex file in path
+ *
+ * @param path carbon file path
+ * @return CarbonFile array
+ */
+ private static CarbonFile[] getCarbonFile(String path, final String
extension) {
+ String dataFilePath = path;
+ if (!(dataFilePath.contains(extension))) {
+ CarbonFile[] carbonFiles = FileFactory
+ .getCarbonFile(path)
+ .listFiles(new CarbonFileFilter() {
+ @Override
+ public boolean accept(CarbonFile file) {
+ if (file == null) {
+ return false;
+ }
+ return file.getName().endsWith(extension);
+ }
+ });
+ if (carbonFiles == null || carbonFiles.length < 1) {
+ throw new RuntimeException("Carbon file not exists.");
+ }
+ return carbonFiles;
+ }
+ return null;
+ }
+
+ /**
+ * read schema from path,
+ * path can be folder path, carbonindex file path, and carbondata file
path
+ * and will not check all files schema
+ *
+ * @param path file/folder path
+ * @return schema
+ * @throws IOException
+ */
+ public static Schema readSchema(String path) throws IOException {
+ return readSchema(path, false);
+ }
+
+ /**
+ * read schema from path,
+ * path can be folder path, carbonindex file path, and carbondata file
path
+ * and user can decide whether check all files schema
+ *
+ * @param path file/folder path
+ * @param checkFilesSchema whether check all files schema
+ * @return schema
+ * @throws IOException
+ */
+ public static Schema readSchema(String path, boolean checkFilesSchema)
throws IOException {
--- End diff --
readSchema(String path, boolean checkFilesSchema)
-- Is this schema validation method is required ? If no use case we can
skip this.. during query execution anyways schema is validated.
---