Class ElasticsearchFieldResolver
- java.lang.Object
-
- com.amazonaws.athena.connectors.elasticsearch.ElasticsearchFieldResolver
-
- All Implemented Interfaces:
FieldResolver
public class ElasticsearchFieldResolver extends Object implements FieldResolver
Used to resolve Elasticsearch complex structures to Apache Arrow Types.- See Also:
FieldResolver
-
-
Field Summary
-
Fields inherited from interface com.amazonaws.athena.connector.lambda.data.FieldResolver
DEFAULT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ElasticsearchFieldResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
coerceListField(org.apache.arrow.vector.types.pojo.Field field, Object fieldValue)
Allows for coercion of a list of values where the returned types do not match the schema.Object
getFieldValue(org.apache.arrow.vector.types.pojo.Field field, Object originalValue)
Return the field value from a complex structure or list.Object
getMapKey(org.apache.arrow.vector.types.pojo.Field field, Object originalValue)
Allow for additional logic to be apply for the retrieval of map keys If not overwritten, the default behavior is to assume a standard map with no special logic where the key is NOT a complex valueObject
getMapValue(org.apache.arrow.vector.types.pojo.Field field, Object originalValue)
Allow for additional logic to be apply for the retrieval of map values If not overwritten, the default behavior is to assume a standard map with no special logic and return the value directly
-
-
-
Method Detail
-
getFieldValue
public Object getFieldValue(org.apache.arrow.vector.types.pojo.Field field, Object originalValue) throws RuntimeException
Return the field value from a complex structure or list.- Specified by:
getFieldValue
in interfaceFieldResolver
- Parameters:
field
- is the field that we would like to extract from the provided value.originalValue
- is the original value object.- Returns:
- the field's value as a List for a LIST field type, a Map for a STRUCT field type, or the actual value if neither of the above.
- Throws:
IllegalArgumentException
- if originalValue is not an instance of Map.RuntimeException
- if the fieldName does not exist in originalValue, if the fieldType is a STRUCT and the fieldValue is not instance of Map, or if the fieldType is neither a LIST or a STRUCT but the fieldValue is instance of Map (STRUCT).
-
getMapKey
public Object getMapKey(org.apache.arrow.vector.types.pojo.Field field, Object originalValue)
Description copied from interface:FieldResolver
Allow for additional logic to be apply for the retrieval of map keys If not overwritten, the default behavior is to assume a standard map with no special logic where the key is NOT a complex value- Specified by:
getMapKey
in interfaceFieldResolver
- Parameters:
field
- The field that we would like to extract from the provided value.originalValue
- The complex value we'd like to extract the provided field from.- Returns:
- The value to use for the given field.
-
getMapValue
public Object getMapValue(org.apache.arrow.vector.types.pojo.Field field, Object originalValue)
Description copied from interface:FieldResolver
Allow for additional logic to be apply for the retrieval of map values If not overwritten, the default behavior is to assume a standard map with no special logic and return the value directly- Specified by:
getMapValue
in interfaceFieldResolver
- Parameters:
field
- The field that we would like to extract from the provided value.originalValue
- The complex value we'd like to extract the provided field from.- Returns:
- The value to use for the given field.
-
coerceListField
protected Object coerceListField(org.apache.arrow.vector.types.pojo.Field field, Object fieldValue) throws RuntimeException
Allows for coercion of a list of values where the returned types do not match the schema. Multiple fields in Elasticsearch can be returned as a string, numeric (Integer, Long, Double), or null.- Parameters:
field
- is the field that we are coercing the value into.fieldValue
- is the list of value to coerce- Returns:
- the coerced list of value.
- Throws:
RuntimeException
- if the fieldType is not a LIST or the fieldValue is instanceof Map (STRUCT).
-
-