Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/996#discussion_r145564952
--- 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 --
Is the schema a single name? Probably not since we are talking about common
prefixes.
Drill supports names with dots. This is done by using an object per name
part. (A `NamePart` in a `SchemaPath`.) Here are we concatenating the names? If
so, won't e have false matches?
```
['a', 'b.c'] --> "a.b.c"
['a.b', 'c'] --> "a.b.c"
```
The above are two distinct paths, but they will (wrongly) compare equals
when concatenated.
Instead, do we want a list of name parts, and want to compare the names
part by part? Does Calcite represent the path as a collection of objects? (If
not, we've got larger problems...)
---