Search in sources :

Example 6 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testExtractRegularExpressionFunctionForHive.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
 *
 * case 2:Hive database expression
 */
@Test
public void testExtractRegularExpressionFunctionForHive() {
    DbmsLanguage netezzaDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.HIVEDEFAULTURL);
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // Hive Database
    // $NON-NLS-1$
    createExpression.setBody("**");
    // $NON-NLS-1$
    String regularFunctionName = netezzaDbmsLanguage.extractRegularExpressionFunction(createExpression, "***");
    // $NON-NLS-1$
    Assert.assertEquals("REGEXP", regularFunctionName);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Example 7 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testSetFunctionReturnValueCase5.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
 *
 * case 5:normal case
 */
@Test
public void testSetFunctionReturnValueCase5() {
    // $NON-NLS-1$
    DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(DbmsLanguage.MSSQL, "1.0");
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // default Database
    // $NON-NLS-1$
    createExpression.setBody("**** WHEN RegularFunctionName(***)returnValue THEN **)****");
    // $NON-NLS-1$
    dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(createExpression, "***"));
    String regularfunctionReturnValue = dbmsLanguage.getFunctionReturnValue();
    // $NON-NLS-1$
    Assert.assertEquals("RETURNVALUE", regularfunctionReturnValue);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Example 8 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testIsApplicable.

/**
 * Test method for {@link org.talend.dq.dbms.DbmsLanguage#isApplicable(orgomg.cwm.objectmodel.core.Expression)}.
 */
@Test
public void testIsApplicable() {
    try {
        // $NON-NLS-1$
        Expression createExpression = createExpression("Mysql");
        DbmsLanguage dbms = getMysqlDbmsLanguage();
        Assert.assertTrue(dbms.isApplicable(createExpression));
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Example 9 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testSetFunctionReturnValueCase2.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
 *
 * case 2:Can not find the keyword for "when" in the body of expression.
 */
@Test
public void testSetFunctionReturnValueCase2() {
    // $NON-NLS-1$
    DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(DbmsLanguage.MSSQL, "1.0");
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // default Database
    // $NON-NLS-1$
    createExpression.setBody("**** RegularFunctionName(***)returnValue THEN **)****");
    // $NON-NLS-1$
    dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(createExpression, "***"));
    String regularfunctionReturnValue = dbmsLanguage.getFunctionReturnValue();
    Assert.assertEquals(StringUtils.EMPTY, regularfunctionReturnValue);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Example 10 with Expression

use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testExtractRegularExpressionFunctionForMssql.

/**
 * {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
 *
 * case 8:Mssql database expression
 */
@Test
public void testExtractRegularExpressionFunctionForMssql() {
    DbmsLanguage mssqlDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.MSSQL2008URL);
    Expression createExpression = CoreFactory.eINSTANCE.createExpression();
    // netezza Database UDP mode
    createExpression.setBody(// $NON-NLS-1$
    "SELECT COUNT(CASE WHEN dbo.fn_prec_match(<%=__COLUMN_NAMES__%>,<%=__PATTERN_EXPR__%>)=1 THEN 1 END), COUNT(*) FROM <%=__TABLE_NAME__%> <%=__WHERE_CLAUSE__%>");
    String regularFunctionName = mssqlDbmsLanguage.extractRegularExpressionFunction(createExpression, // $NON-NLS-1$
    "<%=__PATTERN_EXPR__%>");
    // $NON-NLS-1$
    Assert.assertEquals("dbo.fn_prec_match".toUpperCase(), regularFunctionName);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) Expression(orgomg.cwm.objectmodel.core.Expression) Test(org.junit.Test)

Aggregations

Expression (orgomg.cwm.objectmodel.core.Expression)71 TdExpression (org.talend.cwm.relational.TdExpression)42 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)37 Test (org.junit.Test)25 Domain (org.talend.dataquality.domain.Domain)14 ArrayList (java.util.ArrayList)13 TdColumn (org.talend.cwm.relational.TdColumn)11 Pattern (org.talend.dataquality.domain.pattern.Pattern)10 Catalog (orgomg.cwm.resource.relational.Catalog)10 Indicator (org.talend.dataquality.indicators.Indicator)9 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)8 Analysis (org.talend.dataquality.analysis.Analysis)7 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)7 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)7 DbmsLanguage (org.talend.dq.dbms.DbmsLanguage)7 Connection (org.talend.core.model.metadata.builder.connection.Connection)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)6 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)6 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)6