Search in sources :

Example 1 with GetInfoType

use of org.apache.hive.service.cli.GetInfoType in project cdap by caskdata.

the class BaseHiveExploreService method getInfo.

@Override
public MetaDataInfo getInfo(MetaDataInfo.InfoType infoType) throws ExploreException, SQLException {
    startAndWait();
    try {
        MetaDataInfo ret = infoType.getDefaultValue();
        if (ret != null) {
            return ret;
        }
        SessionHandle sessionHandle = null;
        Map<String, String> sessionConf = startSession();
        try {
            sessionHandle = openHiveSession(sessionConf);
            // Convert to GetInfoType
            GetInfoType hiveInfoType = null;
            for (GetInfoType t : GetInfoType.values()) {
                if (t.name().equals("CLI_" + infoType.name())) {
                    hiveInfoType = t;
                    break;
                }
            }
            if (hiveInfoType == null) {
                // Should not come here, unless there is a mismatch between Explore and Hive info types.
                LOG.warn("Could not find Hive info type %s", infoType);
                return null;
            }
            GetInfoValue val = cliService.getInfo(sessionHandle, hiveInfoType);
            LOG.trace("Retrieving info: {}, got value {}", infoType, val);
            return new MetaDataInfo(val.getStringValue(), val.getShortValue(), val.getIntValue(), val.getLongValue());
        } finally {
            closeInternal(getQueryHandle(sessionConf), new ReadOnlyOperationInfo(sessionHandle, null, sessionConf, "", ""));
        }
    } catch (HiveSQLException e) {
        throw getSqlException(e);
    } catch (Throwable e) {
        throw new ExploreException(e);
    }
}
Also used : GetInfoType(org.apache.hive.service.cli.GetInfoType) GetInfoValue(org.apache.hive.service.cli.GetInfoValue) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) SessionHandle(org.apache.hive.service.cli.SessionHandle) MetaDataInfo(co.cask.cdap.explore.service.MetaDataInfo) ExploreException(co.cask.cdap.explore.service.ExploreException)

Aggregations

ExploreException (co.cask.cdap.explore.service.ExploreException)1 MetaDataInfo (co.cask.cdap.explore.service.MetaDataInfo)1 GetInfoType (org.apache.hive.service.cli.GetInfoType)1 GetInfoValue (org.apache.hive.service.cli.GetInfoValue)1 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)1 SessionHandle (org.apache.hive.service.cli.SessionHandle)1