Misleading error when Hivestats can't be created When Update Statistics is performed on a Hive table, the trafodion.hivestats schema is created if it doesn't already exist. If the user issuing the ustat statement does not have the create_schema component privilege, this will fail, but the code as it existed ignored the error, assuming it was a "schema already exists" error, which is expected in most cases. If the schema does not exist, an error is then given when an attempt is made to create the histograms table in the non-existing schema.
This has been changed to check the error when the schema creation attempt fails, so the correct error is generated. This is a partial fix, because a user with manage_statistics privilege should not be prevented from executing Update Statistics just because the trafodion.hivestats schema did not already exist. The likely full solution would be to create the schema automatically at Trafodion initialization.
Automated collection of necessary statistics When the optimizer requests a histogram for a given column, and that histogram does not exist, it may (depending on the cqds in effect) register a request for the histogram to be created at a later time, or utilize a small sample to generate a rudimentary histogram on the fly. In either case, when a subsequent Update Statistics statements specifies the ON NECESSARY COLUMNS clause, any column of the target table that has been the subject of one of these actions will have a bona fide histogram created.