Skip to content

Commit ee69c13

Browse files
committed
Working on SQL
1 parent c10feea commit ee69c13

File tree

8 files changed

+601
-12
lines changed

8 files changed

+601
-12
lines changed

contrib/format-daffodil/README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
# Daffodil 'Format' Reader
1+
# Daffodil Format Reader
22
This plugin enables Drill to read DFDL-described data from files by way of the Apache Daffodil DFDL implementation.
33

4-
## Validation
4+
## Configuration:
5+
To use Daffodil schemata, simply add the following to the `formats` section of a file-based storage plugin:
56

6-
Data read by Daffodil is always validated using Daffodil's Limited Validation mode.
7+
```json
8+
"daffodil": {
9+
"type": "daffodil",
10+
"extensions": [
11+
"dat"
12+
]
13+
}
14+
```
15+
There are four other optional parameters which you can specify:
16+
* `schemaURI`: Pre-compiled dfdl schema (.bin extension) or DFDL schema source (.xsd extension)
17+
* `validationMode`: Use `true` to request Daffodil built-in limited validation. Use `false` for no validation.
18+
* `rootName`: Local name of root element of the message. Can be null to use the first element declaration of the primary schema file. Ignored if reloading a pre-compiled schema.
19+
* `rootNameSpace`: Namespace URI as a string. Can be `null` to use the target namespace of the primary schema file or if it is unambiguous what element is the rootName. Ignored if reloading a pre-compiled schema.
720

8-
TBD: do we need an option to control escalating validation errors to fatal? Currently this is not provided.
21+
## Usage:
922

10-
## Limitations: TBD
1123

12-
At the moment, the DFDL schema is found on the local file system, which won't support Drill's distributed architecture.
1324

14-
There are restrictions on the DFDL schemas that this can handle.
25+
## Limitations:
26+
At the moment, the DFDL schema is found on the local file system, which won't support Drill's distributed architecture.
1527

16-
In particular, all element children must have distinct element names, including across choice branches.
17-
(This rules out a number of large DFDL schemas.)
28+
There are restrictions on the DFDL schemas that this can handle. In particular, all element children must have distinct element names, including across choice branches. Unfortunately, this rules out a number of large DFDL schemas.
1829

1930
TBD: Auto renaming as part of the Daffodil-to-Drill metadata mapping?
2031

21-
The data is parsed fully from its native form into a Drill data structure held in memory.
22-
No attempt is made to avoid access to parts of the DFDL-described data that are not needed to answer the query.
32+
The data is parsed fully from its native form into a Drill data structure held in memory. No attempt is made to avoid access to parts of the DFDL-described data that are not needed to answer the query.
2333

2434
If the data is not well-formed, an error occurs and the query fails.
2535

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.drill.exec.store.daffodil;
20+
21+
import org.apache.drill.test.BaseTestQuery;
22+
import org.junit.Test;
23+
24+
public class TestDynamicSchemata extends BaseTestQuery {
25+
26+
@Test
27+
public void testSchema() throws Exception {
28+
test("CREATE DAFFODIL SCHEMA USING JAR 'xxx.jar'");
29+
30+
}
31+
}

exec/java-exec/src/main/codegen/data/Parser.tdd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
# List of keywords.
3232
keywords: [
33+
"DAFFODIL",
3334
"DATABASES",
3435
"SCHEMAS",
3536
"TABLES",
@@ -67,6 +68,8 @@
6768
"SqlRefreshMetadata()",
6869
"SqlCreateFunction()",
6970
"SqlDropFunction()",
71+
"SqlCreateDaffodilSchema()",
72+
"SqlDropDaffodilSchema()",
7073
"SqlAnalyzeTable()",
7174
"DrillSqlSetOption(Span.of(), null)",
7275
"DrillSqlResetOption(Span.of(), null)",

exec/java-exec/src/main/codegen/includes/parserImpls.ftl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,48 @@ SqlNode SqlDropFunction() :
687687
}
688688
}
689689

690+
/**
691+
* Parse create Daffodil Schema statement
692+
* CREATE DAFFODIL SCHEMA USING JAR 'jar_name'
693+
*/
694+
SqlNode SqlCreateDaffodilSchema() :
695+
{
696+
SqlParserPos pos;
697+
SqlNode jar;
698+
}
699+
{
700+
<CREATE> { pos = getPos(); }
701+
<DAFFODIL>
702+
<SCHEMA>
703+
<USING>
704+
<JAR>
705+
jar = StringLiteral()
706+
{
707+
return new SqlCreateDaffodilSchema(pos, jar);
708+
}
709+
}
710+
711+
/**
712+
* Parse drop UDF statement
713+
* DROP DAFFODIL SCHEMA USING JAR 'jar_name'
714+
*/
715+
SqlNode SqlDropDaffodilSchema() :
716+
{
717+
SqlParserPos pos;
718+
SqlNode jar;
719+
}
720+
{
721+
<DROP> { pos = getPos(); }
722+
<DAFFODIL>
723+
<SCHEMA>
724+
<USING>
725+
<JAR>
726+
jar = StringLiteral()
727+
{
728+
return new SqlDropDaffodilSchema(pos, jar);
729+
}
730+
}
731+
690732
/**
691733
* Parses a analyze statements:
692734
* <ul>

0 commit comments

Comments
 (0)