class UDFBuilder extends AnyRef
This class allows you to build a UDF that executes an addressing operation. You can obtain an instance of this builder by starting with an AddressingBuilder.
- Alphabetic
- By Inheritance
- UDFBuilder
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def forCustomExecutor(addressingExecutor: AddressingExecutor): UserDefinedFunction
Build a UDF to execute a custom Addressing operation on an address, based on the provided configuration options.
Build a UDF to execute a custom Addressing operation on an address, based on the provided configuration options. This UDF has a single argument that is a map of String to Column. The String keys are the address fields that are to be populated in the RequestAddress, and the column is the value to populate the fields with.
This example uses the returned UDF as "customUdf" and adds an "addressing_result" column to the DataFrameval resultDataFrame = inputDataFrame.withColumn("addressing_result", customUdf(map( lit("addressNumber"), col("addressNum"), lit("street"), col("street"), lit("city"), col("city"), lit("admin1"), col("state"), lit("postalCode"), col("zip"), lit("country"), col("country")) ))
- returns
A UDF that executes a custom Addressing operation.
- def forGeocode(udfName: String): UserDefinedFunction
Register a UDF to geocode an address, based on the provided configuration options.
Register a UDF to geocode an address, based on the provided configuration options. This UDF has a single argument that is a map of String to Column. The String keys are the address fields that are to be populated in the RequestAddress, and the column is the value to populate the fields with.
This example uses the registered UDF as "geocode" and adds an "addressing_result" column to the DataFrame:val geocodeSqlOutput = spark.sql("select *, geocode(map('addressLines[0]', address, 'country', country)) as addressing_result from inputTable")
- returns
A UDF that executes the geocode operation of the Addressing API.
- def forGeocode(): UserDefinedFunction
Build a UDF to geocode an address, based on the provided configuration options.
Build a UDF to geocode an address, based on the provided configuration options. This UDF has a single argument that is a map of String to Column. The String keys are the address fields that are to be populated in the RequestAddress, and the column is the value to populate the fields with.
This example uses the returned UDF as "addressingUdf" and adds an "addressing_result" column to the DataFrame:val resultDataFrame = inputDataFrame.withColumn("addressing_result", addressingUdf(map( lit("addressNumber"), col("addressNum"), lit("street"), col("street"), lit("city"), col("city"), lit("admin1"), col("state"), lit("postalCode"), col("zip"), lit("country"), col("country")) ))
- returns
A UDF that executes the geocode operation of the Addressing API.
- def forLookup(udfName: String): UserDefinedFunction
Register a UDF to 'Lookup' a geocoded candidates when given a unique key, based on the provided configuration options.
Register a UDF to 'Lookup' a geocoded candidates when given a unique key, based on the provided configuration options. This UDF takes two arguments, lookupType Key type- it can be GNAF_PID or PBKEY, Key to search and country.
This example uses the registered UDF as "lookupUdf" and adds an "addressing_result" column to the DataFrame:val lookupSqlOutput = spark.sql("select *, lookupUdf('PB_KEY',key,'USA') as addressing_result from inputTable")
- returns
A UDF that provides a Key Lookup operation.
- def forLookup(): UserDefinedFunction
Build a UDF to 'lookup' a geocoded candidates when given a unique key, based on the provided configuration options.
Build a UDF to 'lookup' a geocoded candidates when given a unique key, based on the provided configuration options. This UDF takes two arguments, lookupType Key type- it can be GNAF_PID or PBKEY, Key to search and country.
This example uses the returned UDF as "addressingUdf" and adds an "addressing_result" column to the DataFrame:val resultDataFrame = inputDataFrame.withColumn("addressing_result", addressingUdf(lit("PB_KEY"), col("key"), lit("USA") ))
- returns
A UDF that provides a Key Lookup operation.
- def forReverseGeocode(udfName: String): UserDefinedFunction
Register a UDF to reverse geocode a location, based on the provided configuration options.
Register a UDF to reverse geocode a location, based on the provided configuration options. This UDF takes X and Y coordinates of location to reverse geocode with optional country parameter.
This example uses the registered UDF as "reverseGeocode" and adds an "addressing_result" column to the DataFrame:val reverseGeocodeSqlOutput = spark.sql("select *, reverseGeocode(x, y, country) as addressing_result from inputTable")
- returns
A UDF that executes the reverse geocode operation of the Addressing API.
- def forReverseGeocode(): UserDefinedFunction
Build a UDF to reverse geocode a location, based on the provided configuration options.
Build a UDF to reverse geocode a location, based on the provided configuration options. This UDF takes X and Y coordinates of location to reverse geocode with optional country parameter.
This example uses the returned UDF as "addressingUdf" and adds an "addressing_result" column to the DataFrame:val resultDataFrame = inputDataFrame.withColumn("addressing_result", addressingUdf( col("x"), col("y"), col("country")) )
- returns
A UDF that executes the reverse geocode operation of the Addressing API.
- def forVerify(udfName: String): UserDefinedFunction
Register a UDF to verify an address, based on the provided configuration options.
Register a UDF to verify an address, based on the provided configuration options. This UDF has a single argument that is a map of String to Column. The String keys are the address fields that are to be populated in the RequestAddress, and the column is the value to populate the fields with.
This example uses the registered UDF as "addressingUdf" and adds an "addressing_result" column to the DataFrame:val verifySqlOutput = spark.sql("select *, verify(map('addressLines[0]', address, 'country', country)) as addressing_result from inputTable")
- returns
A UDF that provides a verify operation.
- def forVerify(): UserDefinedFunction
Build a UDF to verify an address, based on the provided configuration options.
Build a UDF to verify an address, based on the provided configuration options. This UDF has a single argument that is a map of String to Column. The String keys are the address fields that are to be populated in the RequestAddress, and the column is the value to populate the fields with.
This example uses the returned UDF as "addressingUdf" and adds an "addressing_result" column to the DataFrame:val resultDataFrame = inputDataFrame.withColumn("addressing_result", addressingUdf(map( lit("addressNumber"), col("addressNum"), lit("street"), col("street"), lit("city"), col("city"), lit("admin1"), col("state"), lit("postalCode"), col("zip"), lit("country"), col("country")) ))
- returns
A UDF that provides a verify operation.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withErrorField(errorOutputFieldName: String): UDFBuilder
Adds an output field for errors.
Adds an output field for errors. Exceptions during processing of a record are caught and then the message is placed in this output field.
- errorOutputFieldName
The name for the field in the output that any error message is placed.
- def withMultipleResults(): UDFBuilder
Changes the output of the UDF from a single row of output fields, taken from the top candidate, to an array of rows of output fields, one for each result in the response.
Changes the output of the UDF from a single row of output fields, taken from the top candidate, to an array of rows of output fields, one for each result in the response. Note: In order to get back multiple results, preferences must be set to allow that.
- def withOutputFields(fieldNames: String*): UDFBuilder
Adds output fields for the UDF.
Adds output fields for the UDF. Allows you to access any part of the Addressing API Result class. You can use a simple object notation to access sub objects:
Accessing properties:- Use property name, case of first letter is flexible, i.e. "score" would return the value in Result.score
- Accessing nested properties can be done using a period, i.e. "address.formattedAddress" would return the value
in Result.address.formattedAddress
Accessing Lists and Arrays: - Use index values in square brackets, i.e. "addressLines[0]" would return the first element of Result.addressLines
Accessing Maps: - Use square brackets and string literal values, i.e. "parsed['ggs']" would return the value associated with 'ggs' in the Result.parsed map
While evaluating the object notation any nulls encountered along the path will cause a null value to be returned. A property that isn't found will result in an error.
The output field notation also allows aliasing: - You can use a simple 'as' syntax with an alpha numeric alias, i.e. "address.formattedAddress as address" would have an output field name of 'address'
- If you need special characters in the output field name you can use a quoted literal for the alias, i.e. "address.formattedAddress as 'formatted_address'" would have an output field name of 'formatted_address'
- fieldNames
The object notation access field names, which will also be the UDF output field names.
- def withPreferences(preferences: Preferences): UDFBuilder
Sets the preferences that will be used for all geocode calls.
Sets the preferences that will be used for all geocode calls.
- preferences
A preferences instance.
- def withPreferencesFile(file: String): UDFBuilder
Sets the location of a yaml configuration file with the desired preferences.
Sets the location of a yaml configuration file with the desired preferences. Any specific preferences set in this yaml will override the preferences provided by withPreferences
- file
The location of a yaml configuration file.
- def withResultAsJSON(jsonOutputFieldName: String): UDFBuilder
Adds an output field for Json response.
Adds an output field for Json response. Exceptions during processing of a record are caught and then the message is placed in the error field.
- jsonOutputFieldName
The name for the field in the output where that json Response is placed.
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)