org.pentaho.aggdes.model.Dialect Java Examples
The following examples show how to use
org.pentaho.aggdes.model.Dialect.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MondrianMeasure.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
public String getDatatype(Dialect dialect) { final RolapAggregator aggregator = measure.getAggregator(); String aggregatorName = aggregator.getName().toUpperCase(); final mondrian.spi.Dialect mondrianDialect = ((MondrianDialect) dialect).getMondrianDialect(); if (aggregator == RolapAggregator.Min || aggregator == RolapAggregator.Max) { return measure.getDatatypeString(mondrianDialect); } else if (aggregator == RolapAggregator.Count || aggregator == RolapAggregator.DistinctCount) { return dialect.getIntegerTypeString(); } else if (aggregator == RolapAggregator.Sum || aggregator == RolapAggregator.Avg) { return dialect.getDoubleTypeString(); } else { throw new RuntimeException( "Unknown aggregator " + aggregatorName); } }
Example #2
Source File: PopulateTableGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String generate(Schema schema, Output output) { AggregateTableOutput tableOutput = (AggregateTableOutput)output; final Dialect dialect = schema.getDialect(); final StringBuilder buf = new StringBuilder(); dialect.comment(buf, "Populate aggregate table " + tableOutput.getTableName()); buf.append("INSERT INTO "); dialect.quoteIdentifier( buf, tableOutput.getCatalogName(), tableOutput.getSchemaName(), tableOutput.getTableName()); buf.append(" (").append(ResultHandlerImpl.NL); int k = -1; List<String> columnNameList = new ArrayList<String>(); for (AggregateTableOutput.ColumnOutput column : tableOutput.getColumnOutputs()) { ++k; if (k > 0) { buf.append(",").append(ResultHandlerImpl.NL); } buf.append(" "); dialect.quoteIdentifier(buf, column.getName()); columnNameList.add(column.getName()); } buf.append(")").append(ResultHandlerImpl.NL); String sql = schema.generateAggregateSql( tableOutput.getAggregate(), columnNameList); buf.append(sql); dialect.terminateCommand(buf); return buf.toString(); }
Example #3
Source File: CreateTableGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
/** * generates the table output * @param schema * @param output * @return */ public String generate(Schema schema, Output output) { AggregateTableOutput tableOutput = (AggregateTableOutput)output; final Dialect dialect = schema.getDialect(); final StringBuilder buf = new StringBuilder(); dialect.comment( buf, "Aggregate table " + tableOutput.getTableName()); dialect.comment( buf, "Estimated " + new Double(output.getAggregate().estimateRowCount()).intValue() + " rows, " + new Double(output.getAggregate().estimateSpace()).intValue() + " bytes"); buf.append("CREATE TABLE "); dialect.quoteIdentifier(buf, tableOutput.getCatalogName(), tableOutput.getSchemaName(), tableOutput.getTableName()); buf.append(" (").append(ResultHandlerImpl.NL); int i = -1; for (AggregateTableOutput.ColumnOutput columns : tableOutput.getColumnOutputs()) { ++i; if (i > 0) { buf.append(",").append(ResultHandlerImpl.NL); } String columnName = columns.getName(); buf.append(" "); dialect.quoteIdentifier(buf, columnName); buf.append(" "); buf.append(columns.getAttribute().getDatatype(dialect)); } buf.append(")"); dialect.terminateCommand(buf); return buf.toString(); }
Example #4
Source File: MondrianAttribute.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String getDatatype(Dialect dialect) { //TODO: fix mondrian's RolapStar.Column.getDatatypeString() method // so Oracle can work with it. // return column.getDatatypeString( // ((MondrianDialectImpl) dialect).dialect); return internalGetDatatypeString( column, dialect); }
Example #5
Source File: MondrianDialect.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public MondrianDialect( mondrian.spi.Dialect dialect ) { this.dialect = dialect; }
Example #6
Source File: SchemaStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public Dialect getDialect() { return dialect; }
Example #7
Source File: SchemaStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void setDialect(Dialect dialect) { this.dialect = dialect; }
Example #8
Source File: SchemaStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public String getDatatype(Dialect dialect) { return datatype; }
Example #9
Source File: AlgorithmStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public String getDatatype(Dialect dialect) { // TODO Auto-generated method stub return null; }
Example #10
Source File: MondrianDialect.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public mondrian.spi.Dialect getMondrianDialect() { return dialect; }
Example #11
Source File: TileSuggester.java From Bats with Apache License 2.0 | 4 votes |
public Dialect getDialect() { throw new UnsupportedOperationException(); }
Example #12
Source File: MondrianAttribute.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
/** * Returns a string representation of the datatype of this column, in * the dialect specified. For example, 'DECIMAL(10, 2) NOT NULL'. * * @param column RolapStar column * @param dialect Dialect * @return String representation of column's datatype */ private String internalGetDatatypeString(RolapStar.Column column, Dialect dialect) { mondrian.spi.Dialect mondrianDialect = ((MondrianDialect) dialect).getMondrianDialect(); final SqlQuery query = new SqlQuery(mondrianDialect); query.addFrom(column.getTable().getRelation(), column.getTable().getAlias(), false); query.addSelect(column.getExpression().getExpression(query), null); final String sql = query.toString(); java.sql.Connection jdbcConnection = null; try { jdbcConnection = column.getStar().getDataSource().getConnection(); final PreparedStatement pstmt = jdbcConnection.prepareStatement(sql); pstmt.setMaxRows(1); pstmt.executeQuery(); final ResultSetMetaData resultSetMetaData = pstmt.getMetaData(); assert resultSetMetaData.getColumnCount() == 1; final String type = resultSetMetaData.getColumnTypeName(1); int precision = resultSetMetaData.getPrecision(1); final int scale = resultSetMetaData.getScale(1); if (type.equals("DOUBLE")) { precision = 0; } String typeString; if (precision == 0 || precision == Integer.MAX_VALUE || !dialect.supportsPrecision(jdbcConnection.getMetaData(), type)) { typeString = type; } else if (scale == 0) { if(!resultSetMetaData.isSigned(1) && type.contains("UNSIGNED")) { String[] words = type.split("\\s+"); if(words.length > 1) { String typeFirstWord = words[0]; String typeSignWord = words[1]; typeString = typeFirstWord + "(" + precision + ") " + typeSignWord; } else { typeString = type + "(" + precision + ")"; } } else { typeString = type + "(" + precision + ")"; } } else { if(!resultSetMetaData.isSigned(1) && type.contains("UNSIGNED")) { String[] words = type.split("\\s+"); if(words.length > 1) { String typeFirstWord = words[0]; String typeSignWord = words[1]; typeString = typeFirstWord + "(" + precision + ", " + scale + ")" + " " + typeSignWord; } else { typeString = type + "(" + precision + ", " + scale + ")"; } } else { typeString = type + "(" + precision + ", " + scale + ")"; } } pstmt.close(); jdbcConnection.close(); jdbcConnection = null; return typeString; } catch (SQLException e) { throw Util.newError( e, "Error while deriving type of column " + toString()); } finally { if (jdbcConnection != null) { try { jdbcConnection.close(); } catch (SQLException e) { // ignore } } } }
Example #13
Source File: MondrianSchema.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public Dialect getDialect() { return dialect; }
Example #14
Source File: TileSuggester.java From calcite with Apache License 2.0 | 4 votes |
public String getDatatype(Dialect dialect) { return null; }
Example #15
Source File: TileSuggester.java From calcite with Apache License 2.0 | 4 votes |
public Dialect getDialect() { throw new UnsupportedOperationException(); }
Example #16
Source File: TileSuggester.java From Quicksql with MIT License | 4 votes |
public String getDatatype(Dialect dialect) { return null; }
Example #17
Source File: TileSuggester.java From Quicksql with MIT License | 4 votes |
public Dialect getDialect() { throw new UnsupportedOperationException(); }
Example #18
Source File: TileSuggester.java From Bats with Apache License 2.0 | 4 votes |
public String getDatatype(Dialect dialect) { return null; }