Tug's blog > docs explain need for dist. fs
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/98dfbea8 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/98dfbea8 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/98dfbea8 Branch: refs/heads/gh-pages Commit: 98dfbea8bb57f9262ebb65b8a48ed42ccf683c5a Parents: 1fc4d00 Author: Kristine Hahn <[email protected]> Authored: Wed Jul 29 17:22:58 2015 -0700 Committer: Kristine Hahn <[email protected]> Committed: Wed Jul 29 17:27:13 2015 -0700 ---------------------------------------------------------------------- _data/docs.json | 129 ++++++---- .../040-file-system-storage-plugin.md | 4 +- ...010-develop-custom-functions-introduction.md | 10 +- .../020-develop-a-simple-function.md | 50 ---- .../020-developing-a-simple-function.md | 51 ++++ .../025-tutorial-develop-a-simple-function.md | 233 +++++++++++++++++++ .../030-developing-an-aggregate-function.md | 4 +- _docs/getting-started/020-why-drill.md | 6 +- 8 files changed, 388 insertions(+), 99 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/98dfbea8/_data/docs.json ---------------------------------------------------------------------- diff --git a/_data/docs.json b/_data/docs.json index 8e5e5e6..c0b2194 100644 --- a/_data/docs.json +++ b/_data/docs.json @@ -2449,8 +2449,8 @@ } ], "children": [], - "next_title": "Develop a Simple Function", - "next_url": "/docs/develop-a-simple-function/", + "next_title": "Developing a Simple Function", + "next_url": "/docs/developing-a-simple-function/", "parent": "Develop Custom Functions", "previous_title": "Develop Custom Functions", "previous_url": "/docs/develop-custom-functions/", @@ -2466,14 +2466,31 @@ } ], "children": [], - "next_title": "Developing an Aggregate Function", - "next_url": "/docs/developing-an-aggregate-function/", + "next_title": "Tutorial: Develop a Simple Function", + "next_url": "/docs/tutorial-develop-a-simple-function/", "parent": "Develop Custom Functions", "previous_title": "Develop Custom Functions Introduction", "previous_url": "/docs/develop-custom-functions-introduction/", - "relative_path": "_docs/develop-custom-functions/020-develop-a-simple-function.md", - "title": "Develop a Simple Function", - "url": "/docs/develop-a-simple-function/" + "relative_path": "_docs/develop-custom-functions/020-developing-a-simple-function.md", + "title": "Developing a Simple Function", + "url": "/docs/developing-a-simple-function/" + }, + { + "breadcrumbs": [ + { + "title": "Develop Custom Functions", + "url": "/docs/develop-custom-functions/" + } + ], + "children": [], + "next_title": "Developing an Aggregate Function", + "next_url": "/docs/developing-an-aggregate-function/", + "parent": "Develop Custom Functions", + "previous_title": "Developing a Simple Function", + "previous_url": "/docs/developing-a-simple-function/", + "relative_path": "_docs/develop-custom-functions/025-tutorial-develop-a-simple-function.md", + "title": "Tutorial: Develop a Simple Function", + "url": "/docs/tutorial-develop-a-simple-function/" }, { "breadcrumbs": [ @@ -2486,8 +2503,8 @@ "next_title": "Adding Custom Functions to Drill", "next_url": "/docs/adding-custom-functions-to-drill/", "parent": "Develop Custom Functions", - "previous_title": "Develop a Simple Function", - "previous_url": "/docs/develop-a-simple-function/", + "previous_title": "Tutorial: Develop a Simple Function", + "previous_url": "/docs/tutorial-develop-a-simple-function/", "relative_path": "_docs/develop-custom-functions/030-developing-an-aggregate-function.md", "title": "Developing an Aggregate Function", "url": "/docs/developing-an-aggregate-function/" @@ -2561,8 +2578,8 @@ } ], "children": [], - "next_title": "Develop a Simple Function", - "next_url": "/docs/develop-a-simple-function/", + "next_title": "Developing a Simple Function", + "next_url": "/docs/developing-a-simple-function/", "parent": "Develop Custom Functions", "previous_title": "Develop Custom Functions", "previous_url": "/docs/develop-custom-functions/", @@ -2630,23 +2647,6 @@ "title": "Develop Drill", "url": "/docs/develop-drill/" }, - "Develop a Simple Function": { - "breadcrumbs": [ - { - "title": "Develop Custom Functions", - "url": "/docs/develop-custom-functions/" - } - ], - "children": [], - "next_title": "Developing an Aggregate Function", - "next_url": "/docs/developing-an-aggregate-function/", - "parent": "Develop Custom Functions", - "previous_title": "Develop Custom Functions Introduction", - "previous_url": "/docs/develop-custom-functions-introduction/", - "relative_path": "_docs/develop-custom-functions/020-develop-a-simple-function.md", - "title": "Develop a Simple Function", - "url": "/docs/develop-a-simple-function/" - }, "Developer Information": { "breadcrumbs": [], "children": [ @@ -2903,6 +2903,23 @@ "title": "Developer Information", "url": "/docs/developer-information/" }, + "Developing a Simple Function": { + "breadcrumbs": [ + { + "title": "Develop Custom Functions", + "url": "/docs/develop-custom-functions/" + } + ], + "children": [], + "next_title": "Tutorial: Develop a Simple Function", + "next_url": "/docs/tutorial-develop-a-simple-function/", + "parent": "Develop Custom Functions", + "previous_title": "Develop Custom Functions Introduction", + "previous_url": "/docs/develop-custom-functions-introduction/", + "relative_path": "_docs/develop-custom-functions/020-developing-a-simple-function.md", + "title": "Developing a Simple Function", + "url": "/docs/developing-a-simple-function/" + }, "Developing an Aggregate Function": { "breadcrumbs": [ { @@ -2914,8 +2931,8 @@ "next_title": "Adding Custom Functions to Drill", "next_url": "/docs/adding-custom-functions-to-drill/", "parent": "Develop Custom Functions", - "previous_title": "Develop a Simple Function", - "previous_url": "/docs/develop-a-simple-function/", + "previous_title": "Tutorial: Develop a Simple Function", + "previous_url": "/docs/tutorial-develop-a-simple-function/", "relative_path": "_docs/develop-custom-functions/030-developing-an-aggregate-function.md", "title": "Developing an Aggregate Function", "url": "/docs/developing-an-aggregate-function/" @@ -10448,6 +10465,23 @@ "title": "Troubleshooting", "url": "/docs/troubleshooting/" }, + "Tutorial: Develop a Simple Function": { + "breadcrumbs": [ + { + "title": "Develop Custom Functions", + "url": "/docs/develop-custom-functions/" + } + ], + "children": [], + "next_title": "Developing an Aggregate Function", + "next_url": "/docs/developing-an-aggregate-function/", + "parent": "Develop Custom Functions", + "previous_title": "Developing a Simple Function", + "previous_url": "/docs/developing-a-simple-function/", + "relative_path": "_docs/develop-custom-functions/025-tutorial-develop-a-simple-function.md", + "title": "Tutorial: Develop a Simple Function", + "url": "/docs/tutorial-develop-a-simple-function/" + }, "Tutorials": { "breadcrumbs": [], "children": [ @@ -15195,8 +15229,8 @@ } ], "children": [], - "next_title": "Develop a Simple Function", - "next_url": "/docs/develop-a-simple-function/", + "next_title": "Developing a Simple Function", + "next_url": "/docs/developing-a-simple-function/", "parent": "Develop Custom Functions", "previous_title": "Develop Custom Functions", "previous_url": "/docs/develop-custom-functions/", @@ -15212,14 +15246,31 @@ } ], "children": [], - "next_title": "Developing an Aggregate Function", - "next_url": "/docs/developing-an-aggregate-function/", + "next_title": "Tutorial: Develop a Simple Function", + "next_url": "/docs/tutorial-develop-a-simple-function/", "parent": "Develop Custom Functions", "previous_title": "Develop Custom Functions Introduction", "previous_url": "/docs/develop-custom-functions-introduction/", - "relative_path": "_docs/develop-custom-functions/020-develop-a-simple-function.md", - "title": "Develop a Simple Function", - "url": "/docs/develop-a-simple-function/" + "relative_path": "_docs/develop-custom-functions/020-developing-a-simple-function.md", + "title": "Developing a Simple Function", + "url": "/docs/developing-a-simple-function/" + }, + { + "breadcrumbs": [ + { + "title": "Develop Custom Functions", + "url": "/docs/develop-custom-functions/" + } + ], + "children": [], + "next_title": "Developing an Aggregate Function", + "next_url": "/docs/developing-an-aggregate-function/", + "parent": "Develop Custom Functions", + "previous_title": "Developing a Simple Function", + "previous_url": "/docs/developing-a-simple-function/", + "relative_path": "_docs/develop-custom-functions/025-tutorial-develop-a-simple-function.md", + "title": "Tutorial: Develop a Simple Function", + "url": "/docs/tutorial-develop-a-simple-function/" }, { "breadcrumbs": [ @@ -15232,8 +15283,8 @@ "next_title": "Adding Custom Functions to Drill", "next_url": "/docs/adding-custom-functions-to-drill/", "parent": "Develop Custom Functions", - "previous_title": "Develop a Simple Function", - "previous_url": "/docs/develop-a-simple-function/", + "previous_title": "Tutorial: Develop a Simple Function", + "previous_url": "/docs/tutorial-develop-a-simple-function/", "relative_path": "_docs/develop-custom-functions/030-developing-an-aggregate-function.md", "title": "Developing an Aggregate Function", "url": "/docs/developing-an-aggregate-function/" http://git-wip-us.apache.org/repos/asf/drill/blob/98dfbea8/_docs/connect-a-data-source/040-file-system-storage-plugin.md ---------------------------------------------------------------------- diff --git a/_docs/connect-a-data-source/040-file-system-storage-plugin.md b/_docs/connect-a-data-source/040-file-system-storage-plugin.md index 3380d28..3f68781 100644 --- a/_docs/connect-a-data-source/040-file-system-storage-plugin.md +++ b/_docs/connect-a-data-source/040-file-system-storage-plugin.md @@ -9,7 +9,9 @@ system on your machine by default. ## Connecting Drill to a File System -In a Drill cluster, you typically do not query the local file system, but instead place files on the distributed file system. You configure the connection property of the storage plugin workspace to connect Drill to a distributed file system. For example, the following connection property connects Drill to an HDFS cluster from a client: +In a Drill cluster, you typically do not query the local file system, but instead place files on the distributed file system. Currently, you need to use a distributed file system when connecting multiple Drillbits to get complete, consistent query results. + +You configure the connection property of the storage plugin workspace to connect Drill to a distributed file system. For example, the following connection property connects Drill to an HDFS cluster from a client: `"connection": "hdfs://<IP Address>:<Port>/"` http://git-wip-us.apache.org/repos/asf/drill/blob/98dfbea8/_docs/develop-custom-functions/010-develop-custom-functions-introduction.md ---------------------------------------------------------------------- diff --git a/_docs/develop-custom-functions/010-develop-custom-functions-introduction.md b/_docs/develop-custom-functions/010-develop-custom-functions-introduction.md index b3841ed..f8cd3b8 100644 --- a/_docs/develop-custom-functions/010-develop-custom-functions-introduction.md +++ b/_docs/develop-custom-functions/010-develop-custom-functions-introduction.md @@ -3,23 +3,25 @@ title: "Develop Custom Functions Introduction" parent: "Develop Custom Functions" --- Drill provides a high performance Java API with interfaces that you can -implement to develop simple and aggregate custom functions. Custom functions +implement to develop simple custom functions. Custom functions are reusable SQL functions that you develop in Java to encapsulate code that -processes column values during a query. Custom functions can perform +processes column values during a query. Custom functions have all the performance of the Drill primitive operations. Custom functions can perform calculations and transformations that built-in SQL operators and functions do not provide. Custom functions are called from within a SQL statement, like a regular function, and return a single value. +This section includes a [tutorial]({{site.baseurl}}/docs/tutorial-develop-a-simple-function/) for creating a simple function that is based on a github project, which you can download. + ## Simple Function A simple function operates on a single row and produces a single row as the output. When you include a simple function in a query, the function is called once for each row in the result set. Mathematical and string functions are -examples of simple functions. +examples of simple functions. ## Aggregate Function -Aggregate functions differ from simple functions in the number of rows that +The API for developing aggregate custom functions is at the alpha stage and intended for experimental use only. Aggregate functions differ from simple functions in the number of rows that they accept as input. An aggregate function operates on multiple input rows and produces a single row as output. The COUNT(), MAX(), SUM(), and AVG() functions are examples of aggregate functions. You can use an aggregate http://git-wip-us.apache.org/repos/asf/drill/blob/98dfbea8/_docs/develop-custom-functions/020-develop-a-simple-function.md ---------------------------------------------------------------------- diff --git a/_docs/develop-custom-functions/020-develop-a-simple-function.md b/_docs/develop-custom-functions/020-develop-a-simple-function.md deleted file mode 100644 index cc0c899..0000000 --- a/_docs/develop-custom-functions/020-develop-a-simple-function.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: "Develop a Simple Function" -parent: "Develop Custom Functions" ---- -Create a class within a Java package that implements Drillâs simple interface -into the program, and include the required information for the function type. -Your function must include data types that Drill supports, such as INTEGER or -BIGINT. For a list of supported data types, refer to the [SQL Reference]({{ site.baseurl }}/docs/supported-data-types/). - -Complete the following steps to develop a simple function using Drillâs simple -function interface: - - 1. Create a Maven project and add the following dependency: - - <dependency> - <groupId>org.apache.drill.exec</groupId> - <artifactId>drill-java-exec</artifactId> - <version>1.1.0</version> - </dependency> - - 2. Create a class that implements the `DrillSimpleFunc` interface and identify the scope as `FunctionScope.SIMPLE`. - - **Example** - - @FunctionTemplate(name = "myaddints", scope = FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL) - public static class IntIntAdd implements DrillSimpleFunc { - - 3. Provide the variables used in the code in the `Param` and `Output` bit holders. - - **Example** - - @Param IntHolder in1; - @Param IntHolder in2; - @Output IntHolder out; - - 4. Add the code that performs operations for the function in the `eval()` method. - - **Example** - - public void setup() { - } - public void eval() { - out.value = in1.value + in2.value; - } - - 5. Use the maven-source-plugin to compile the sources and classes JAR files. Verify that an empty `drill-module.conf` is included in the resources folder of the JARs. -Drill searches this module during classpath scanning. If the file is not -included in the resources folder, you can add it to the JAR file or add it to -`etc/drill/conf`. - http://git-wip-us.apache.org/repos/asf/drill/blob/98dfbea8/_docs/develop-custom-functions/020-developing-a-simple-function.md ---------------------------------------------------------------------- diff --git a/_docs/develop-custom-functions/020-developing-a-simple-function.md b/_docs/develop-custom-functions/020-developing-a-simple-function.md new file mode 100644 index 0000000..e807e89 --- /dev/null +++ b/_docs/develop-custom-functions/020-developing-a-simple-function.md @@ -0,0 +1,51 @@ +--- +title: "Developing a Simple Function" +parent: "Develop Custom Functions" +--- +The section presents a brief overview of developing a simple function. The [tutorial]({{site.baseurl}}/docs/tutorial-develop-a-simple-function/) in the next section covers how to create a simple function in more depth. + +To develop a simple function, you need to create a class within a Java package that implements Drillâs simple interface +into the program, and include the required information for the function type. +Your function must use [data types]({{ site.baseurl }}/docs/supported-data-types/) that Drill supports. + +Complete the following steps to develop a simple function using Drillâs simple +function interface: + + 1. Create a Maven project and add the following dependency: + + <dependency> + <groupId>org.apache.drill.exec</groupId> + <artifactId>drill-java-exec</artifactId> + <version>1.1.0</version> + </dependency> + + 2. Create a class that implements the `DrillSimpleFunc` interface and identify the scope as `FunctionScope.SIMPLE`. + + **Example** + + @FunctionTemplate(name = "myaddints", scope = FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL) + public static class IntIntAdd implements DrillSimpleFunc { + + 3. Provide the variables used in the code in the `Param` and `Output` bit holders. + + **Example** + + @Param IntHolder in1; + @Param IntHolder in2; + @Output IntHolder out; + + 4. Add the code that performs operations for the function in the eval() method. + + **Example** + + public void setup() { + } + public void eval() { + out.value = in1.value + in2.value; + } + + 5. Use the maven-source-plugin to compile the sources and classes JAR files. Verify that an empty `drill-module.conf` is included in the resources folder. +Drill searches this module during classpath scanning. If the file is not +included in the resources folder, you can add it to the JAR file or add it to +`etc/drill/conf`. + http://git-wip-us.apache.org/repos/asf/drill/blob/98dfbea8/_docs/develop-custom-functions/025-tutorial-develop-a-simple-function.md ---------------------------------------------------------------------- diff --git a/_docs/develop-custom-functions/025-tutorial-develop-a-simple-function.md b/_docs/develop-custom-functions/025-tutorial-develop-a-simple-function.md new file mode 100644 index 0000000..c65f8f5 --- /dev/null +++ b/_docs/develop-custom-functions/025-tutorial-develop-a-simple-function.md @@ -0,0 +1,233 @@ +--- +title: "Tutorial: Develop a Simple Function" +parent: "Develop Custom Functions" +--- + +You can create complex functions having advanced features, but for example purposes, this tutorial covers how to create a simple MASK function. You extend the Drill query engine using the Drill Simple Function interface: + +```java +package org.apache.drill.contrib.function; + +import org.apache.drill.exec.expr.DrillSimpleFunc; +import org.apache.drill.exec.expr.annotations.FunctionTemplate; + +@FunctionTemplate( + /* Add annotations name, scope, and nulls */ +) + +public class SimpleMaskFunc implements DrillSimpleFunc{ + + public void setup() { + } + public void eval() { + } +} +``` + +The MASK function transforms the value of a column on each row. The function masks characters in a string, as shown by the following pseudo-code: + +`MASK( 'PASSWORD' , '#' , 4 ) => ####WORD` + +The MASK function replaces a given number of characters from the beginning of a string with another character. In this example, MASK replaces four characters with the # character. + +You can get the complete project for creating and building this function from the [drill-simple-mask-function Github repository](https://github.com/tgrall/drill-simple-mask-function). + +## Prerequisites + +* [Oracle Java SE Development (JDK) Kit 7](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html) or later +* [Apache Drill 1.1](http://getdrill.org/drill/download/apache-drill-1.1.0.tar.gz) or later +* [Maven 3.0](https://maven.apache.org/download.cgi) or later + +---------- + +## Step 1: Add dependencies + +First, add the following Drill dependency to your maven project: + +```xml + <dependency> + <groupId>org.apache.drill.exec</groupId> + <artifactId>drill-java-exec</artifactId> + <version>1.1.0</version> + </dependency> +``` +---------- + +## Step 2: Implement the function template + +In the @FunctionTemplate declaration, add the following annotations: + +* Name of the custom function + `name="mask"` +* Scope of the custom function, in this case, Simple + `scope= FunctionTemplate.FunctionScope.SIMPLE` +* What to do when the value is NULL, in this case Reverse will just returns NULL + `nulls = FunctionTemplate.NullHandling.NULL_IF_NULL` + +```java +. . . +@FunctionTemplate( + name = "mask", + scope = FunctionTemplate.FunctionScope.SIMPLE, + nulls = FunctionTemplate.NullHandling.NULL_IF_NULL +) + +public class SimpleMaskFunc implements DrillSimpleFunc{ +. . . +} +``` + +---------- + +## Step 3: Declare input parameters + +The eval() method that you implement appears to have no parameters. By examining the simple function interface [source code](https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillSimpleFuncHolder.java#L42), you can see that Drill generates the function dynamically, and in this case, requires declaration of the following input parameters using the @Param annotation: + +* A nullable string +* The mask char or string +* The number of characters to replace starting from the first + +For each of these parameters, use a holder class: VarCharHolder or NullableVarCharHolder. + +```java +. . . +public class SimpleMaskFunc implements DrillSimpleFunc { + + @Param + NullableVarCharHolder input; + + @Param(constant = true) + VarCharHolder mask; + + @Param(constant = true) + IntHolder toReplace; +. . . +} +``` + +{% include startnote.html %}Drill doesnât actually use the Java heap for data being processed in a query but instead keeps this data off the heap and manages the life-cycle for us without using the Java garbage collector.{% include endnote.html %} + + +---------- + +## Step 4: Declare the return value type + +The eval() method that you implement appears to return void, but from simple function interface, but the MASK function returns a string. To declare the return value type, use the @Output annotation and declare the type to be of the VarCharHolder type. Also, because you are manipulating a VarChar, you also have to inject a buffer that Drill uses for the output. + +```java + +public class SimpleMaskFunc implements DrillSimpleFunc { +. . . + @Output + VarCharHolder out; + + @Inject + DrillBuf buffer; +. . . +} +``` + +---------- + +## Step 5: Implement the eval() method + +The MASK function does not require any setup, so you do not need to define the setup() method. Define only the eval() method. + +```java +public void eval() { + + // get the value and replace with + String maskValue = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getStringFromVarCharHolder(mask); + String stringValue = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(input.start, input.end, input.buffer); + + int numberOfCharToReplace = Math.min(toReplace.value, stringValue.length()); + + // build the mask substring + String maskSubString = com.google.common.base.Strings.repeat(maskValue, numberOfCharToReplace); + String outputValue = (new StringBuilder(maskSubString)).append(stringValue.substring(numberOfCharToReplace)).toString(); + + // put the output value in the out buffer + out.buffer = buffer; + out.start = 0; + out.end = outputValue.getBytes().length; + buffer.setBytes(0, outputValue.getBytes()); +} +``` + +The eval() method performs the following tasks: + +* Gets the mask +* Gets the value +* Gets the number of character to replace +* Generates a new string with masked values +* Creates and populates the output buffer + +Even to a seasoned Java developer, the eval() method might look a bit mysterious because Drill generates the final code on the fly to fulfill a query request. This technique leverages Javaâs just-in-time (JIT) compiler for maximum speed. + +## Basic Coding Rules +To leverage Javaâs just-in-time (JIT) compiler for maximum speed, you need to adhere to some basic rules. + +* Do not use imports. Instead, use the fully qualified class name as required by the Google Guava API packaged in Apache Drill and as shown in ["Step 3: Declare input parameters"]({{site.baseurl}}/docs/tutorial-develop-a-simple-function/#step-3-declare-input-parameters). +* Manipulate the ValueHolders classes, for example VarCharHolder and IntHolder, as structs by calling helper methods, such as getStringFromVarCharHolder and toStringFromUTF8 as shown in ["Step 5: Implement the eval() function"]({{site.baseurl}}/docs/tutorial-develop-a-simple-function/#step-5-implement-the-eval-function). +* Do not call methods such as toString because this causes serious problems. + + +## Complete Code Listing + +The Github drill-simple-mask-function project includes the [complete listing](https://github.com/tgrall/drill-simple-mask-function/blob/master/src/main/java/org/apache/drill/contrib/function/SimpleMaskFunc.java) of the code for the MASK function. + +## Prepare the Package + +Because Drill generates the source, you must prepare your package such that classes and sources of the function are present in the classpath. The classes and sources are required for the necessary code generation. Drill uses the compiled code to access the annotations and uses the source code to do code generation. This packaging differs from the way Java code is typically packaged. + +For simplicity, use maven to build your project in a pom.xml file as follows: + +```xml +<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.4</version> + <executions> + <execution> + <id>attach-sources</id> + <phase>package</phase> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> +</plugin> +``` + +## Build and Deploy the Function +Build the function using mvn package: + +`mvn clean package` + +Maven generates two JAR files: + +* The default jar with the classes and resources (drill-simple-mask-1.0.jar) +* A second jar with the sources (drill-simple-mask-1.0-sources.jar) + +Copy the JAR files to the following location: + +`<Drill installation directory>/jars/3rdparty` + +## Add a drill-module.conf File to Resources +Add a `drill-module.conf` file in the resources folder of your project. The presence of this file tells Drill that your jar contains a custom function. If you have no specific configuration to set for your function, you can keep this file empty. + +## Test the New Function + +Restart drill and run the following query: + + SELECT MASK(first_name, '*' , 3) FIRST , MASK(last_name, '#', 7) LAST FROM cp.`employee.json` LIMIT 5; + +----------+------------+ + | FIRST | LAST | + +----------+------------+ + | ***ri | ###### | + | ***rick | ####### | + | ***hael | ###### | + | ***a | #######ez | + | ***erta | ####### | + +----------+------------+ + 5 rows selected (2.259 seconds) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/drill/blob/98dfbea8/_docs/develop-custom-functions/030-developing-an-aggregate-function.md ---------------------------------------------------------------------- diff --git a/_docs/develop-custom-functions/030-developing-an-aggregate-function.md b/_docs/develop-custom-functions/030-developing-an-aggregate-function.md index 45ecf3c..fbbec2a 100644 --- a/_docs/develop-custom-functions/030-developing-an-aggregate-function.md +++ b/_docs/develop-custom-functions/030-developing-an-aggregate-function.md @@ -2,7 +2,7 @@ title: "Developing an Aggregate Function" parent: "Develop Custom Functions" --- -Create a class within a Java package that implements Drillâs aggregate +The API for developing aggregate custom functions is at the alpha stage and intended for experimental use only. To experiment with this API, create a class within a Java package that implements Drillâs aggregate interface into the program. Include the required information for the function. Your function must include data types that Drill supports, such as INTEGER or BIGINT. For a list of supported data types, refer to the [SQL Reference]({{ site.baseurl }}/docs/supported-data-types/). @@ -29,7 +29,7 @@ Complete the following steps to create an aggregate function: @Param BitHolder in; @Workspace BitHolder value; @Output BitHolder out; - 4. Include the `setup(), add(), output(),` and `reset()` methods. + 4. Include the setup(), add(), output(),` and `reset() methods. **Example** public void setup() { http://git-wip-us.apache.org/repos/asf/drill/blob/98dfbea8/_docs/getting-started/020-why-drill.md ---------------------------------------------------------------------- diff --git a/_docs/getting-started/020-why-drill.md b/_docs/getting-started/020-why-drill.md index 2e57b88..de9beb3 100644 --- a/_docs/getting-started/020-why-drill.md +++ b/_docs/getting-started/020-why-drill.md @@ -7,7 +7,7 @@ parent: "Getting Started" ### 1. Get started in minutes -It takes a couple of minutes to start working with Drill. Untar the Drill software on your Mac or Windows laptop and run a query on a local file. No need to set up any infrastructure or to define schemas. Just point to the data, such as data in a file, directory, HBase table, and drill. +It takes just a few minutes to get started with Drill. Untar the Drill software on your Mac or Windows laptop and run a query on a local file. No need to set up any infrastructure or to define schemas. Just point to the data, such as data in a file, directory, HBase table, and drill. $ tar -xvf apache-drill-<version>.tar.gz $ <install directory>/bin/drill-embedded @@ -74,8 +74,8 @@ Drill is extensible. You can connect Drill out-of-the-box to file systems (local GROUP BY custview.membership ORDER BY 2; -## 8. User-Defined Functions (UDFs) -Drill exposes a simple and high-performance Java API to build custom functions (UDFs and UDAFs) so that you can add your own business logic. If you have already built UDFs in Hive, you can reuse them with Drill with no modifications. Refer to [Developing Custom Functions](({{ site.baseurl }}/docs/develop-custom-functions/) for more information. +## 8. User-Defined Functions (UDFs) for Drill and Hive +Drill exposes a simple, high-performance Java API to build [custom user-defined functions]({{ site.baseurl }}/docs/develop-custom-functions/) (UDFs) for adding your own business logic to Drill. Drill also supports Hive UDFs. If you have already built UDFs in Hive, you can reuse them with Drill with no modifications. ## 9. High performance
