public PrestoSqlWarning(Warning warning) { //TODO: enforce that sqlState is 01[5,6,7,8,9,I-Z][0-9A-Z]{3} // From the SQL Standard ISO_IEC_9075-2E_2016 24.1 SQLState: warning codes have class 01 // warning subclasses defined in the sql state will start with [0-4A-H] and contain 3 characters // An example of vendor specific warning codes can be found here: // https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/codes/src/tpc/db2z_sqlstatevalues.html#db2z_sqlstatevalues__code01 // Note that the subclass begins with 5 which indicates it is an implementation defined subclass super(warning.getMessage(), warning.getWarningCode().getName(), warning.getWarningCode().getCode()); } }
private static boolean isQuery(StatementClient client) { String updateType; if (client.isRunning()) { updateType = client.currentStatusInfo().getUpdateType(); } else { updateType = client.finalStatusInfo().getUpdateType(); } return updateType == null; }
private static RuntimeException getCause(QueryError queryError) { if (queryError.getFailureInfo() != null) { return queryError.getFailureInfo().toException(); } return null; }
public static ClientSession stripTransactionId(ClientSession session) { return ClientSession.builder(session) .withoutTransactionId() .build(); }
@Test public void testFormat() { assertMillis(0, "0 00:00:00.000"); assertMillis(1, "0 00:00:00.001"); assertMillis(-1, "-0 00:00:00.001"); assertMillis(toMillis(12, 13, 45, 56, 789), "12 13:45:56.789"); assertMillis(toMillis(-12, -13, -45, -56, -789), "-12 13:45:56.789"); assertMillis(Long.MAX_VALUE, "106751991167 07:12:55.807"); assertMillis(Long.MIN_VALUE + 1, "-106751991167 07:12:55.807"); assertMillis(Long.MIN_VALUE, "-106751991167 07:12:55.808"); }
@Override public void cancelLeafStage() { checkState(!isClientAborted(), "client is closed"); URI uri = currentStatusInfo().getPartialCancelUri(); if (uri != null) { httpDelete(uri); } }
@Override public void close() { // If the query is not done, abort the query. if (state.compareAndSet(State.RUNNING, State.CLIENT_ABORTED)) { URI uri = currentResults.get().getNextUri(); if (uri != null) { httpDelete(uri); } } }
@Override public String toString() { return formatMillis(milliSeconds); } }
@Override public String toString() { return formatMonths(months); } }
@Override public String getDatabaseProductVersion() throws SQLException { return connection.getServerInfo().getNodeVersion().getVersion(); }
@Override public String getVersion() { return nodeVersion.getVersion(); }
@Override public void close() { client.close(); }
private synchronized Session getSession() throws LoginException, GSSException { if ((clientSession == null) || clientSession.needsRefresh()) { clientSession = createSession(); } return clientSession; }
public Optional<String> getSetPath() { return client.getSetPath(); }
public boolean isClearTransactionId() { return client.isClearTransactionId(); }
@Override public String toString() { String message = getMessage(); if (message != null) { return type + ": " + message; } return type; } }
public static StatementClient newStatementClient(OkHttpClient httpClient, ClientSession session, String query) { return new StatementClientV1(httpClient, session, query); } }
@Test public void testFormat() { assertMillis(0, "0 00:00:00.000"); assertMillis(1, "0 00:00:00.001"); assertMillis(-1, "-0 00:00:00.001"); assertMillis(toMillis(12, 13, 45, 56, 789), "12 13:45:56.789"); assertMillis(toMillis(-12, -13, -45, -56, -789), "-12 13:45:56.789"); assertMillis(Long.MAX_VALUE, "106751991167 07:12:55.807"); assertMillis(Long.MIN_VALUE + 1, "-106751991167 07:12:55.807"); assertMillis(Long.MIN_VALUE, "-106751991167 07:12:55.808"); }
@Override public String getVersion() { return nodeVersion.getVersion(); }
@Override public void close() { client.close(); }