Affects Version/s: None
Fix Version/s: None
Here is the failing case (it does not yet exists in `optiq` test suite):
/** Tests using case-insensitive matching of table names */
@Test public void testCaseInsensitiveTables()
Validator threw unexpected exception; query [select eMp.* from (select * from emp as EmP)]; exception [Unknown identifier 'eMp']; pos [line 1 col 8 thru line 1 col 8]
I guess the cause is `OptiqCatalogReader` that tries to use `map.get`: `schema.compositeTableMap.get(name)`
I see several possible solutions, however I do not have performance tests, thus I am not sure how to measure the impact.
1) Add one more map that maps `name.toUpper() -> Table`. The problem is `equalsIgnoreCase` is not the same as comparing two strings converted to upper (or lower) case.
See relevant comment in `String#equalsIgnoreCase`:
// If characters don't match but case may be ignored,
// try converting both characters to uppercase.
// If the results match, then the comparison scan should
char u1 = Character.toUpperCase(c1);
char u2 = Character.toUpperCase(c2);
if (u1 == u2)
// Unfortunately, conversion to uppercase does not work properly
// for the Georgian alphabet, which has strange rules about case
// conversion. So we need to make one last check before
if (Character.toLowerCase(u1) == Character.toLowerCase(u2))
2) Use `TreeMap` + `java.text.CollationKey`. This will provide locale-dependent case-insensitive map, however the performance will degrade
3) Use both approaches: use special `HashMap` of previously resolved tables. When no table is found there, look into `TreeMap` as a source-of-case-insensitive-truth.
The same might be relevant for wide types (e.g. types with 1000 columns)