Github user HanumathRao commented on a diff in the pull request:
https://github.com/apache/drill/pull/996#discussion_r146118431
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SchemaUtilites.java
---
@@ -77,6 +77,22 @@ public static SchemaPlus findSchema(final SchemaPlus
defaultSchema, final String
return findSchema(defaultSchema, schemaPathAsList);
}
+ /**
+ * Utility function to get the commonPrefix schema between two supplied
schemas.
+ * @param defaultSchema default schema
+ * @param schemaPath current schema path
+ * @param isCaseSensitive true if caseSensitive comparision is required.
+ * @return common prefix schemaPath
+ */
+ public static String getPrefixSchemaPath(final String defaultSchema,
final String schemaPath, final boolean isCaseSensitive) {
+ if (!isCaseSensitive) {
+ return Strings.commonPrefix(defaultSchema.toLowerCase(),
schemaPath.toLowerCase());
--- End diff --
@paul-rogers Thank you for this catch. I did try out some examples which
were throwing schemanotfound exception. I have changed the code to handle it.
getDefaultSchemaPath of session object returns the defaultSchema as String,
hence I converted the SchemaPath to String by SchemaPathJOINER. As pointed out
by your comment, this will loose some context information if the "." is part of
the name. However, I also think that there is a bug in the defaultSchema code
path as it is also loosing this information by converting it to String. For now
I am not fixing that bug (which I am planning to fix in another JIRA) as I am
not sure about the changes in setting defaultSchema.
Coming on to the specific valid use case which was throwing schemaNotFound
exception is
in dfs I have introduced "tmp.tmp1" in place of tmp.
And if I query select * from dfs.`tmp.tmp1`.`employee.json` limit 1; this
query reports SchemaNotFound exception even though a workspace with name
tmp.tmp1 exists.
This is currently working with new changes.
---