private static List<ParameterInfo> getParameterInfo(StoredProcedure procedure) { List<ParameterInfo> paramInfos = new ArrayList<ParameterInfo>(); for (SPParameter param : procedure.getParameters()) { ParameterInfo info = new ParameterInfo(param.getParameterType(), param.getResultSetColumns().size()); paramInfos.add(info); } return paramInfos; }
private MetadataResult getMetadataResults() throws SQLException { if (metadataResults == null) { if (StatementImpl.SET_STATEMENT.matcher(prepareSql).matches() || StatementImpl.TRANSACTION_STATEMENT.matcher(prepareSql).matches() || StatementImpl.SHOW_STATEMENT.matcher(prepareSql).matches() || StatementImpl.SET_CHARACTERISTIC_STATEMENT.matcher(prepareSql).matches()) { metadataResults = new MetadataResult(); } else { try { metadataResults = this.getDQP().getMetadata(this.currentRequestID, prepareSql, Boolean.valueOf(getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS)).booleanValue()); } catch (TeiidComponentException e) { throw TeiidSQLException.create(e); } catch (TeiidProcessingException e) { throw TeiidSQLException.create(e); } } } return metadataResults; }
private void loadFullMetadata() throws SQLException { MetadataResult results; try { results = this.statement.getDQP().getMetadata(this.requestID); } catch (TeiidComponentException e) { throw TeiidSQLException.create(e); } catch (TeiidProcessingException e) { throw TeiidSQLException.create(e); } this.metadata = results.getColumnMetadata(); }
while(iteratorOfParameters.hasNext()){ ParameterInfo parameter = (ParameterInfo)iteratorOfParameters.next(); if(parameter.getType() == ParameterInfo.RESULT_SET){ resultSetSize = parameter.getNumColumns(); while(iteratorOfParameters.hasNext()){ ParameterInfo parameter = (ParameterInfo)iteratorOfParameters.next(); if(parameter.getType() == ParameterInfo.RETURN_VALUE){ count++; index++; while(iteratorOfParameters.hasNext()){ ParameterInfo parameter = (ParameterInfo)iteratorOfParameters.next(); if(parameter.getType() != ParameterInfo.RETURN_VALUE && parameter.getType() != ParameterInfo.RESULT_SET){ index++; if(parameter.getType() == ParameterInfo.OUT || parameter.getType() == ParameterInfo.INOUT){ count++; int resultIndex = resultSetSize + count;
public ParameterMetaDataImpl getParameterMetaData() throws SQLException { if (parameterMetaData == null) { //TODO: some of the base implementation of ResultSetMetadata could be on the MetadataProvider this.parameterMetaData = new ParameterMetaDataImpl(new ResultSetMetaDataImpl(new MetadataProvider(getMetadataResults().getParameterMetadata()), this.getExecutionProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS))); } return parameterMetaData; }
private static List<ParameterInfo> getParameterInfo(StoredProcedure procedure) { List<ParameterInfo> paramInfos = new ArrayList<ParameterInfo>(); for (SPParameter param : procedure.getParameters()) { ParameterInfo info = new ParameterInfo(param.getParameterType(), param.getResultSetColumns().size()); paramInfos.add(info); } return paramInfos; }
while(iteratorOfParameters.hasNext()){ ParameterInfo parameter = (ParameterInfo)iteratorOfParameters.next(); if(parameter.getType() == ParameterInfo.RESULT_SET){ resultSetSize = parameter.getNumColumns(); while(iteratorOfParameters.hasNext()){ ParameterInfo parameter = (ParameterInfo)iteratorOfParameters.next(); if(parameter.getType() == ParameterInfo.RETURN_VALUE){ count++; index++; while(iteratorOfParameters.hasNext()){ ParameterInfo parameter = (ParameterInfo)iteratorOfParameters.next(); if(parameter.getType() != ParameterInfo.RETURN_VALUE && parameter.getType() != ParameterInfo.RESULT_SET){ index++; if(parameter.getType() == ParameterInfo.OUT || parameter.getType() == ParameterInfo.INOUT){ count++; int resultIndex = resultSetSize + count;
private void loadFullMetadata() throws SQLException { MetadataResult results; try { results = this.statement.getDQP().getMetadata(this.requestID); } catch (TeiidComponentException e) { throw TeiidSQLException.create(e); } catch (TeiidProcessingException e) { throw TeiidSQLException.create(e); } this.metadata = results.getColumnMetadata(); }
private MetadataResult getMetadataResults() throws SQLException { if (metadataResults == null) { if (StatementImpl.SET_STATEMENT.matcher(prepareSql).matches() || StatementImpl.TRANSACTION_STATEMENT.matcher(prepareSql).matches() || StatementImpl.SHOW_STATEMENT.matcher(prepareSql).matches() || StatementImpl.SET_CHARACTERISTIC_STATEMENT.matcher(prepareSql).matches()) { metadataResults = new MetadataResult(); } else { try { metadataResults = this.getDQP().getMetadata(this.currentRequestID, prepareSql, Boolean.valueOf(getExecutionProperty(ExecutionProperties.ANSI_QUOTED_IDENTIFIERS)).booleanValue()); } catch (TeiidComponentException e) { throw TeiidSQLException.create(e); } catch (TeiidProcessingException e) { throw TeiidSQLException.create(e); } } } return metadataResults; }
public ParameterMetaDataImpl getParameterMetaData() throws SQLException { if (parameterMetaData == null) { //TODO: some of the base implementation of ResultSetMetadata could be on the MetadataProvider this.parameterMetaData = new ParameterMetaDataImpl(new ResultSetMetaDataImpl(new MetadataProvider(getMetadataResults().getParameterMetadata()), this.getExecutionProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS))); } return parameterMetaData; }
private static List<ParameterInfo> getParameterInfo(StoredProcedure procedure) { List<ParameterInfo> paramInfos = new ArrayList<ParameterInfo>(); for (SPParameter param : procedure.getParameters()) { ParameterInfo info = new ParameterInfo(param.getParameterType(), param.getResultSetColumns().size()); paramInfos.add(info); } return paramInfos; }
assertEquals(2, copy.getParameters().size()); ParameterInfo info1 = (ParameterInfo) copy.getParameters().get(0); assertEquals(ParameterInfo.IN, info1.getType()); assertEquals(0, info1.getNumColumns()); ParameterInfo info2 = (ParameterInfo) copy.getParameters().get(1); assertEquals(ParameterInfo.RESULT_SET, info2.getType()); assertEquals(5, info2.getNumColumns());
private void helpCheckNumericAttributes(MetadataResult message, int column, int expectedSize, int expectedPrecision, int expectedScale) { Map[] md = message.getColumnMetadata(); assertNotNull(md); assertEquals(new Integer(expectedSize), md[column].get(ResultsMetadataConstants.DISPLAY_SIZE)); assertEquals(new Integer(expectedPrecision), md[column].get(ResultsMetadataConstants.PRECISION)); assertEquals(new Integer(expectedScale), md[column].get(ResultsMetadataConstants.SCALE)); }
message.setLastRow(100); List parameters = new ArrayList(); parameters.add(new ParameterInfo(ParameterInfo.IN, 0)); parameters.add(new ParameterInfo(ParameterInfo.RESULT_SET, 5)); message.setParameters(parameters); PlanNode planDescs = new PlanNode("test");
public ResultSetMetaData getMetaData() throws SQLException { // check if the statement is open checkStatement(); if(metadata == null) { if (updateCounts != null) { return null; } else if(resultSet != null) { metadata = resultSet.getMetaData(); } else { Matcher matcher = StatementImpl.SHOW_STATEMENT.matcher(prepareSql); if (matcher.matches()) { this.executeShow(matcher); metadata = this.resultSet.getMetaData(); this.resultSet = null; return metadata; } if (getMetadataResults().getColumnMetadata() == null || getMetadataResults().getColumnMetadata().length == 0) { return null; } MetadataProvider provider = new MetadataProvider(getMetadataResults().getColumnMetadata()); metadata = new ResultSetMetaDataImpl(provider, this.getExecutionProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS)); } } return metadata; }
@Test public void testGetOutputParameter() throws Exception { CallableStatementImpl mmcs = getCallableStatement(); RequestMessage request = new RequestMessage(); request.setExecutionId(1); ResultsMessage resultsMsg = new ResultsMessage(); List<?>[] results = new List[] {Arrays.asList(null, null, null), Arrays.asList(null, 1, 2)}; resultsMsg.setResults(results); resultsMsg.setColumnNames(new String[] { "IntNum", "Out1", "Out2" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ resultsMsg.setDataTypes(new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER }); resultsMsg.setFinalRow(results.length); resultsMsg.setLastRow(results.length); resultsMsg.setFirstRow(1); resultsMsg.setParameters(Arrays.asList(new ParameterInfo(ParameterInfo.RESULT_SET, 1), new ParameterInfo(ParameterInfo.OUT, 1), new ParameterInfo(ParameterInfo.OUT, 1))); mmcs.createResultSet(resultsMsg); assertEquals(1, mmcs.getInt(1)); assertEquals(2, mmcs.getInt(2)); assertEquals(1, mmcs.getInt("Out1")); assertEquals(2, mmcs.getInt("Out2")); }
public ResultSetMetaData getMetaData() throws SQLException { // check if the statement is open checkStatement(); if(metadata == null) { if (updateCounts != null) { return null; } else if(resultSet != null) { metadata = resultSet.getMetaData(); } else { Matcher matcher = StatementImpl.SHOW_STATEMENT.matcher(prepareSql); if (matcher.matches()) { this.executeShow(matcher); metadata = this.resultSet.getMetaData(); this.resultSet = null; return metadata; } if (getMetadataResults().getColumnMetadata() == null || getMetadataResults().getColumnMetadata().length == 0) { return null; } MetadataProvider provider = new MetadataProvider(getMetadataResults().getColumnMetadata()); metadata = new ResultSetMetaDataImpl(provider, this.getExecutionProperty(ExecutionProperties.JDBC4COLUMNNAMEANDLABELSEMANTICS)); } } return metadata; }
@Test public void testWindowFunction() throws Exception { QueryMetadataInterface metadata = TestMetaDataProcessor.examplePrivatePhysicalModel(); String sql = "SELECT min(e1) over () FROM pm1.g2"; //$NON-NLS-1$ MetadataResult response = helpTestQuery(metadata, sql, TestMetaDataProcessor.examplePrivatePhysicalModelVDB()); helpCheckNumericAttributes(response, 0, 21, 19, 4); assertEquals("e1", response.getColumnMetadata()[0].get(ResultsMetadataConstants.ELEMENT_NAME)); //$NON-NLS-1$ assertEquals("expr1", response.getColumnMetadata()[0].get(ResultsMetadataConstants.ELEMENT_LABEL)); //$NON-NLS-1$ }
@Test public void testArrayAgg() throws Exception { QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); String sql = "SELECT array_agg(e1) FROM pm1.g2"; //$NON-NLS-1$ MetadataResult response = helpTestQuery(metadata, sql, RealMetadataFactory.example1VDB()); assertEquals("string[]", response.getColumnMetadata()[0].get(ResultsMetadataConstants.DATA_TYPE)); }
public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata, VDBMetaData vdb) throws Exception { // Prepare sql Command command = QueryParser.getQueryParser().parseCommand(sql); QueryResolver.resolveCommand(command, metadata); // Create components SessionAwareCache<PreparedPlan> prepPlanCache = new SessionAwareCache<PreparedPlan>("preparedplan", new DefaultCacheFactory(new CacheConfiguration()), SessionAwareCache.Type.PREPAREDPLAN, 0); DQPCore requestMgr = new DQPCore(); requestMgr.setTransactionService(new FakeTransactionService()); DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, vdb); // Initialize components RequestID requestID = workContext.getRequestID(1); RequestMessage requestMsg = new RequestMessage(sql); TestDQPCoreRequestHandling.addRequest(requestMgr, requestMsg, requestID, command, null); MetaDataProcessor mdProc = new MetaDataProcessor(requestMgr, prepPlanCache, "MyVDB", 1); return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata(); }