use of org.talend.dq.dbms.HiveDbmsLanguage in project tdq-studio-se by Talend.
the class RowMatchExplorer method getRowsNotMatchStatement.
/**
* get Rows for NotMatched Statement.
*
* @return
*/
public String getRowsNotMatchStatement() {
ColumnSet tablea = (ColumnSet) indicator.getAnalyzedElement();
String tableA = tablea.getName();
// $NON-NLS-1$
String query = "SELECT A.*" + dbmsLanguage.from();
if (ColumnsetPackage.eINSTANCE.getRowMatchingIndicator() == indicator.eClass()) {
ColumnSet tableb = ColumnHelper.getColumnOwnerAsColumnSet(((RowMatchingIndicator) indicator).getColumnSetB().get(0));
String tableB = tableb.getName();
EList<TdColumn> columnSetA = ((RowMatchingIndicator) indicator).getColumnSetA();
EList<TdColumn> columnSetB = ((RowMatchingIndicator) indicator).getColumnSetB();
// $NON-NLS-1$
String clauseA = " (SELECT *" + dbmsLanguage.from() + getFullyQualifiedTableName(tablea);
// $NON-NLS-1$
String clauseB = " (SELECT *" + dbmsLanguage.from() + getFullyQualifiedTableName(tableb);
String where = null;
// $NON-NLS-1$
String onClause = " ON ";
String realWhereClause = dbmsLanguage.where();
for (int i = 0; i < columnSetA.size(); i++) {
where = dbmsLanguage.and();
if (i == 0) {
where = dbmsLanguage.where();
} else {
onClause += where;
realWhereClause += where;
}
realWhereClause += // $NON-NLS-1$
" B" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetB.get(i).getName()) + dbmsLanguage.isNull();
onClause += // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
" (A" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetA.get(i).getName()) + "=" + " B" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetB.get(i).getName()) + // $NON-NLS-1$
") ";
}
clauseA += (tableA.equals(tableB) ? whereDataFilter(tableA, (getdataFilterIndex(null) == AnalysisHelper.DATA_FILTER_A ? AnalysisHelper.DATA_FILTER_A : AnalysisHelper.DATA_FILTER_B)) : whereDataFilter(tableA, null)) + // $NON-NLS-1$
") A";
clauseB += (tableB.equals(tableA) ? whereDataFilter(tableB, (getdataFilterIndex(null) == AnalysisHelper.DATA_FILTER_A ? AnalysisHelper.DATA_FILTER_B : AnalysisHelper.DATA_FILTER_A)) : whereDataFilter(tableB, null)) + // $NON-NLS-1$
") B";
// MOD qiongli 2012-8-14 TDQ-5907.
if (dbmsLanguage instanceof HiveDbmsLanguage) {
// $NON-NLS-1$
query += clauseA + " LEFT OUTER JOIN " + clauseB + onClause + realWhereClause;
} else {
// $NON-NLS-1$
query += clauseA + " LEFT JOIN " + clauseB + onClause + realWhereClause;
}
}
return getComment(MENU_VIEW_NOT_MATCH_ROWS) + query;
}
use of org.talend.dq.dbms.HiveDbmsLanguage in project tdq-studio-se by Talend.
the class FrequencyStatisticsExplorer method getInstantiatedClause.
/**
* Method "getInstantiatedClause".
*
* @return the where clause from the instantiated query
*/
protected String getInstantiatedClause() {
// get function which convert data into a pattern
TdColumn column = (TdColumn) indicator.getAnalyzedElement();
int javaType = column.getSqlDataType().getJavaDataType();
// MOD mzhao bug 9681 2009-11-09
Object value = null;
if (Java2SqlType.isNumbericInSQL(javaType) && dbmsLanguage instanceof DB2DbmsLanguage) {
value = entity.getKey();
} else if (Java2SqlType.isNumbericInSQL(javaType) && dbmsLanguage instanceof SybaseASEDbmsLanguage) {
value = entity.getKey();
} else if (Java2SqlType.isNumbericInSQL(javaType) && dbmsLanguage instanceof HiveDbmsLanguage) {
value = entity.getKey();
} else {
// $NON-NLS-1$ //$NON-NLS-2$
value = "'" + entity.getKey() + "'";
}
String clause = entity.isLabelNull() ? columnName + dbmsLanguage.isNull() : columnName + dbmsLanguage.equal() + value;
return clause;
}
use of org.talend.dq.dbms.HiveDbmsLanguage in project tdq-studio-se by Talend.
the class SimpleStatisticsExplorer method getSubClassQueryMap.
@Override
public Map<String, String> getSubClassQueryMap() {
Map<String, String> map = new HashMap<String, String>();
// MOD zshen feature 12919 adapt to pop-menu for Jave engin on result page
boolean isSqlEngine = ExecutionLanguage.SQL.equals(this.analysis.getParameters().getExecutionLanguage());
// MOD qiongli 2011-3-4,feature 19192:filter menue 'view rows' for columSet AnalysisType.
AnalysisType analysisType = this.analysis.getParameters().getAnalysisType();
// MOD qiongli 2012-8-29 hive don't support 'where in...'
boolean isHive = dbmsLanguage instanceof HiveDbmsLanguage;
switch(this.indicatorEnum) {
case RowCountIndicatorEnum:
// for columnset/column and jave engine, we didn't show the view rows menu
if (isSqlEngine) {
// when user define indicator
map.put(MENU_VIEW_ROWS, getComment(MENU_VIEW_ROWS) + getRowsStatement());
}
break;
case NullCountIndicatorEnum:
case BlankCountIndicatorEnum:
case DefValueCountIndicatorEnum:
case UserDefinedIndicatorEnum:
// when user define indicator
IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
map.put(MENU_VIEW_ROWS, isSqlEngine ? getComment(MENU_VIEW_ROWS) + (indicatorDefinition instanceof UDIndicatorDefinition ? getQueryForViewRows(indicatorDefinition) : getRowsStatement()) : null);
break;
case UniqueIndicatorEnum:
case DuplicateCountIndicatorEnum:
if (analysisType != AnalysisType.COLUMN_SET) {
if (!isHive) {
map.put(MENU_VIEW_ROWS, isSqlEngine ? getComment(MENU_VIEW_ROWS) + getRowsStatementWithSubQuery() : null);
} else if (!isSqlEngine) {
map.put(MENU_VIEW_ROWS, null);
}
}
map.put(MENU_VIEW_VALUES, isSqlEngine ? getComment(MENU_VIEW_VALUES) + getValuesStatement(this.columnName) : null);
break;
case DistinctCountIndicatorEnum:
map.put(MENU_VIEW_VALUES, isSqlEngine ? getComment(MENU_VIEW_VALUES) + getDistinctValuesStatement(this.columnName) : null);
break;
default:
}
return map;
}
Aggregations