Hello Gang,

I came across an interesting problem and I think the entire community
should be mindful of this situation.

There needs to be better consistency with handling of Object names
(database, tables, column, view, function, etc.).  I think it makes sense
to standardize on the same rules which MySQL/MariaDB uses for their column
names so that Hive can be more of a drop-in replacement for these.

The two important things to keep in mind are:

1// Permitted characters in quoted identifiers include the full Unicode
Basic Multilingual Plane (BMP), except U+0000

2// If any components of a multiple-part name require quoting, quote them
individually rather than quoting the name as a whole. For example, write
`my-table`.`my-column`, not `my-table.my-column`.

https://dev.mysql.com/doc/refman/8.0/en/identifiers.html
https://dev.mysql.com/doc/refman/8.0/en/identifier-qualifiers.html

That is to say:

-- Select all rows from a table named `default.mytable`
-- (Yes, the table name itself has a period in it. This is valid)
SELECT * FROM `default.mytable`;

-- Select all rows from database `default`, table `mytable`
SELECT * FROM `default`.`mytable`;

This plays out in a couple of ways.  There may be more, but these are the
ones I know about already:

1// Hive generates incorrect syntax
https://issues.apache.org/jira/browse/HIVE-23128

2// Hive throws exception if there is a period in the table name.  This is
an invalid response.  Table name may have a period in them. More likely
than not, it will throw 'table not found' exception since the user most
likely accidentally used backticks incorrectly and meant to specify a db
and a table separately.
https://issues.apache.org/jira/browse/HIVE-16907

Thanks.

Reply via email to