use of io.cdap.cdap.explore.service.ExploreException in project cdap by cdapio.
the class ExploreHttpClient method doDisableExploreDataset.
protected QueryHandle doDisableExploreDataset(DatasetId datasetInstance, DatasetSpecification spec) throws ExploreException {
String body = spec == null ? null : GSON.toJson(new DisableExploreParameters(spec));
String endpoint = spec == null ? "disable" : "disable-internal";
HttpResponse response = doPost(String.format("namespaces/%s/data/explore/datasets/%s/%s", datasetInstance.getNamespace(), datasetInstance.getEntityName(), endpoint), body, null);
if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
}
throw new ExploreException(String.format("Cannot disable explore on dataset %s. Reason: %s", datasetInstance.toString(), response));
}
use of io.cdap.cdap.explore.service.ExploreException in project cdap by cdapio.
the class ExploreHttpClient method getFunctions.
@Override
public QueryHandle getFunctions(@Nullable String catalog, @Nullable String schemaPattern, String functionNamePattern) throws ExploreException, SQLException {
String body = GSON.toJson(new FunctionsArgs(catalog, schemaPattern, functionNamePattern));
String resource = String.format("namespaces/%s/data/explore/jdbc/functions", schemaPattern);
HttpResponse response = doPost(resource, body, null);
if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
}
throw new ExploreException("Cannot get the functions. Reason: " + response);
}
use of io.cdap.cdap.explore.service.ExploreException in project cdap by cdapio.
the class ExploreHttpClient method getTableInfo.
@Override
public TableInfo getTableInfo(String namespace, @Nullable String databaseName, String table) throws ExploreException, TableNotFoundException {
String url = String.format("namespaces/%s/data/explore/tables/%s/info", namespace, table);
if (databaseName != null) {
url += "?database=" + databaseName;
}
HttpResponse response = doGet(url);
if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
return parseJson(response, TableInfo.class);
} else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new TableNotFoundException(String.format("Namespace %s, table %s not found.", namespace, table));
}
throw new ExploreException(String.format("Cannot get the schema of namespace %s, table %s. Reason: %s", namespace, table, response));
}
use of io.cdap.cdap.explore.service.ExploreException in project cdap by cdapio.
the class ExploreHttpClient method doPartitionOperation.
private QueryHandle doPartitionOperation(DatasetId datasetId, DatasetSpecification spec, PartitionKey key, String endpoint, String operationName, Map<String, String> additionalArguments) throws ExploreException {
Map<String, String> args = new HashMap<>(additionalArguments);
PartitionedFileSetArguments.setOutputPartitionKey(args, key);
String tableName = ExploreProperties.getExploreTableName(spec.getProperties());
String databaseName = ExploreProperties.getExploreDatabaseName(spec.getProperties());
if (tableName != null) {
args.put(ExploreProperties.PROPERTY_EXPLORE_TABLE_NAME, tableName);
}
if (databaseName != null) {
args.put(ExploreProperties.PROPERTY_EXPLORE_DATABASE_NAME, databaseName);
}
HttpResponse response = doPost(String.format("namespaces/%s/data/explore/datasets/%s/%s", datasetId.getNamespace(), datasetId.getEntityName(), endpoint), GSON.toJson(args), null);
if (response.getResponseCode() == HttpURLConnection.HTTP_OK) {
return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
}
throw new ExploreException(String.format("Cannot %s partition with key %s in dataset %s. Reason: %s", operationName, key, datasetId.toString(), response));
}
use of io.cdap.cdap.explore.service.ExploreException in project cdap by cdapio.
the class ExploreResultSet method getMetaData.
@Override
public ResultSetMetaData getMetaData() throws SQLException {
if (isClosed()) {
throw new SQLException("Resultset is closed");
}
if (metaData == null) {
try {
List<ColumnDesc> columnDescs = executionResult.getResultSchema();
metaData = new ExploreResultSetMetaData(columnDescs);
} catch (ExploreException e) {
LOG.error("Caught exception", e);
throw new SQLException(e);
}
}
return metaData;
}
Aggregations