Package com.asakusafw.dmdl.semantics

Examples of com.asakusafw.dmdl.semantics.ModelDeclaration


     * @throws Exception if failed
     */
    @Test
    public void data_simple() throws Exception {
        Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version);
        ModelDeclaration model = load("simple.dmdl", "simple");
        SheetBuilder builder = new SheetBuilder(workbook, version, model);
        builder.addData("MODEL");

        Sheet sheet = workbook.getSheet("MODEL");
        assertThat(sheet, not(nullValue()));
View Full Code Here


     * @throws Exception if failed
     */
    @Test
    public void data_copy() throws Exception {
        Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version);
        ModelDeclaration model = load("simple.dmdl", "simple");
        SheetBuilder builder = new SheetBuilder(workbook, version, model);
        builder.addData("MODEL");
        builder.addData("COPY");

        Sheet sheet = workbook.getSheet("COPY");
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void data_primitives() throws Exception {
        Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version);
        ModelDeclaration model = load("basic_type.dmdl", "simple");
        SheetBuilder builder = new SheetBuilder(workbook, version, model);
        builder.addData("PRIMITIVES");

        Sheet sheet = workbook.getSheet("PRIMITIVES");
        assertThat(sheet, not(nullValue()));
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void rule() throws Exception {
        Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version);
        ModelDeclaration model = load("basic_type.dmdl", "simple");
        SheetBuilder builder = new SheetBuilder(workbook, version, model);
        builder.addRule("RULE");

        Sheet sheet = workbook.getSheet("RULE");
        checkRuleSheet(sheet, model);
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void rule_copy() throws Exception {
        Workbook workbook = WorkbookGenerator.createEmptyWorkbook(version);
        ModelDeclaration model = load("simple.dmdl", "simple");
        SheetBuilder builder = new SheetBuilder(workbook, version, model);
        builder.addRule("MODEL");
        builder.addRule("COPY");

        Sheet sheet = workbook.getSheet("COPY");
View Full Code Here

    /**
     * simple case.
     */
    @Test
    public void simple() {
        ModelDeclaration model = analyze(new String[] {
                "model = {",
                "  @directio.hive.char(length = 3)",
                "  simple : TEXT;",
                "};"
        }).findModelDeclaration("model");
        PropertyDeclaration property = model.findPropertyDeclaration("simple");
        HiveFieldTrait trait = property.getTrait(HiveFieldTrait.class);
        assertThat(trait, is(notNullValue()));
        assertThat(trait.getTypeKind(), is(HiveFieldTrait.TypeKind.CHAR));
        assertThat(trait.getStringLength(), is(3));
    }
View Full Code Here

    /**
     * simple case.
     */
    @Test
    public void simple() {
        ModelDeclaration model = analyze(new String[] {
                "model = {",
                "  @directio.hive.ignore",
                "  simple : INT;",
                "};"
        }).findModelDeclaration("model");
        PropertyDeclaration property = model.findPropertyDeclaration("simple");
        HiveFieldTrait trait = property.getTrait(HiveFieldTrait.class);
        assertThat(trait, is(notNullValue()));
        assertThat(trait.isColumnPresent(), is(false));
    }
View Full Code Here

    /**
     * simple case.
     */
    @Test
    public void simple() {
        ModelDeclaration model = analyze(new String[] {
                "@directio.hive.orc",
                "model = { simple : INT; };"
        }).findModelDeclaration("model");
        assertThat(model.getTrait(HiveDataModelTrait.class), is(notNullValue()));

        OrcFileTrait trait = model.getTrait(OrcFileTrait.class);
        assertThat(trait, is(notNullValue()));
        assertThat(trait.getOriginalAst(), is(notNullValue()));
        assertThat(trait.getTableName(), is(nullValue()));
        assertThat(trait.configuration().getFieldMappingStrategy(), is(nullValue()));
        assertThat(trait.configuration().getOnMissingSource(), is(nullValue()));
View Full Code Here

    /**
     * explicitly defines all attributes.
     */
    @Test
    public void attributes() {
        ModelDeclaration model = analyze(new String[] {
                "@directio.hive.orc(",
                "  table_name = 'attributes_test',",
                "  field_mapping = 'name',",
                "  on_missing_source = 'ignore',",
                "  on_missing_target = 'fail',",
                "  on_incompatible_type = 'logging',",
                "  format_version = '0.11',",
                "  compression = 'zlib',",
                "  stripe_size = 123456789,",
                ")",
                "model = { simple : INT; };"
        }).findModelDeclaration("model");

        OrcFileTrait trait = model.getTrait(OrcFileTrait.class);
        assertThat(trait, is(notNullValue()));
        assertThat(trait.getOriginalAst(), is(notNullValue()));
        assertThat(trait.getTableName(), is("attributes_test"));
        assertThat(trait.configuration().getFieldMappingStrategy(), is(FieldMappingStrategy.NAME));
        assertThat(trait.configuration().getOnMissingSource(), is(ExceptionHandlingStrategy.IGNORE));
View Full Code Here

    /**
     * simple case.
     */
    @Test
    public void simple() {
        ModelDeclaration model = analyze(new String[] {
                "model = {",
                "  @directio.hive.varchar(length = 3)",
                "  simple : TEXT;",
                "};"
        }).findModelDeclaration("model");
        PropertyDeclaration property = model.findPropertyDeclaration("simple");
        HiveFieldTrait trait = property.getTrait(HiveFieldTrait.class);
        assertThat(trait, is(notNullValue()));
        assertThat(trait.getTypeKind(), is(HiveFieldTrait.TypeKind.VARCHAR));
        assertThat(trait.getStringLength(), is(3));
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.dmdl.semantics.ModelDeclaration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.