use of org.teiid.client.metadata.MetadataResult in project teiid by teiid.
the class TestMetaDataProcessor method testDefect16629_moneyType.
@Test
public void testDefect16629_moneyType() throws Exception {
QueryMetadataInterface metadata = TestMetaDataProcessor.examplePrivatePhysicalModel();
// $NON-NLS-1$
String sql = "SELECT e1 FROM pm1.g2";
MetadataResult response = helpTestQuery(metadata, sql, TestMetaDataProcessor.examplePrivatePhysicalModelVDB());
helpCheckNumericAttributes(response, 0, 21, 19, 4);
}
use of org.teiid.client.metadata.MetadataResult in project teiid by teiid.
the class TestMetaDataProcessor method testArrayAgg.
@Test
public void testArrayAgg() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// $NON-NLS-1$
String sql = "SELECT array_agg(e1) FROM pm1.g2";
MetadataResult response = helpTestQuery(metadata, sql, RealMetadataFactory.example1VDB());
assertEquals("string[]", response.getColumnMetadata()[0].get(ResultsMetadataConstants.DATA_TYPE));
}
use of org.teiid.client.metadata.MetadataResult in project teiid by teiid.
the class TestMetaDataProcessor method testWindowFunction.
@Test
public void testWindowFunction() throws Exception {
QueryMetadataInterface metadata = TestMetaDataProcessor.examplePrivatePhysicalModel();
// $NON-NLS-1$
String sql = "SELECT min(e1) over () FROM pm1.g2";
MetadataResult response = helpTestQuery(metadata, sql, TestMetaDataProcessor.examplePrivatePhysicalModelVDB());
helpCheckNumericAttributes(response, 0, 21, 19, 4);
// $NON-NLS-1$
assertEquals("e1", response.getColumnMetadata()[0].get(ResultsMetadataConstants.ELEMENT_NAME));
// $NON-NLS-1$
assertEquals("expr1", response.getColumnMetadata()[0].get(ResultsMetadataConstants.ELEMENT_LABEL));
}
use of org.teiid.client.metadata.MetadataResult in project teiid by teiid.
the class MetaDataProcessor method getMetadataForCommand.
// For each projected symbol, construct a metadata map
private MetadataResult getMetadataForCommand(Command originalCommand) throws TeiidComponentException {
Map<Integer, Object>[] columnMetadata = null;
switch(originalCommand.getType()) {
case Command.TYPE_QUERY:
if (originalCommand instanceof Query) {
if (((Query) originalCommand).getInto() == null) {
columnMetadata = createProjectedSymbolMetadata(originalCommand);
}
} else {
columnMetadata = createProjectedSymbolMetadata(originalCommand);
}
break;
case Command.TYPE_STORED_PROCEDURE:
columnMetadata = createProjectedSymbolMetadata(originalCommand);
break;
case Command.TYPE_INSERT:
case Command.TYPE_UPDATE:
case Command.TYPE_DELETE:
case Command.TYPE_CREATE:
case Command.TYPE_DROP:
break;
default:
if (originalCommand.returnsResultSet()) {
columnMetadata = createProjectedSymbolMetadata(originalCommand);
}
}
Map<Reference, String> paramMap = Collections.emptyMap();
if (originalCommand instanceof StoredProcedure) {
StoredProcedure sp = (StoredProcedure) originalCommand;
paramMap = new HashMap<Reference, String>();
Collection<SPParameter> params = sp.getParameters();
for (SPParameter spParameter : params) {
if (spParameter.getParameterType() != SPParameter.INOUT && spParameter.getParameterType() != SPParameter.IN && spParameter.getParameterType() != SPParameter.RETURN_VALUE) {
continue;
}
Expression ex = spParameter.getExpression();
if (ex instanceof Function && FunctionLibrary.isConvert((Function) ex)) {
ex = ((Function) ex).getArg(0);
}
if (ex instanceof Reference) {
paramMap.put((Reference) ex, spParameter.getParameterSymbol().getShortName());
}
}
}
List<Reference> params = ReferenceCollectorVisitor.getReferences(originalCommand);
Map<Integer, Object>[] paramMetadata = new Map[params.size()];
for (int i = 0; i < params.size(); i++) {
Reference param = params.get(i);
paramMetadata[i] = getDefaultColumn(null, paramMap.get(param), param.getType());
}
return new MetadataResult(columnMetadata, paramMetadata);
}
use of org.teiid.client.metadata.MetadataResult in project teiid by teiid.
the class TestMetaDataProcessor method testDefect16629_aggregatesOnMoneyType.
@Test
public void testDefect16629_aggregatesOnMoneyType() throws Exception {
QueryMetadataInterface metadata = TestMetaDataProcessor.examplePrivatePhysicalModel();
// $NON-NLS-1$
String sql = "SELECT min(e1), max(e1), sum(e1), avg(e1) FROM pm1.g2";
MetadataResult response = helpTestQuery(metadata, sql, TestMetaDataProcessor.examplePrivatePhysicalModelVDB());
helpCheckNumericAttributes(response, 0, 21, 19, 4);
helpCheckNumericAttributes(response, 1, 21, 19, 4);
helpCheckNumericAttributes(response, 2, 22, 20, 0);
helpCheckNumericAttributes(response, 3, 22, 20, 0);
}
Aggregations