public class FieldPath extends Object
In BigQuery, Snowflake, and other databases with STRUCT/RECORD types,
column references can include field paths like customer.address.city.
This class captures the field path portion (segments beyond the base column).
Design principles:
customer.address.city,
if base column is customer, fieldPath stores ["address", "city"])Example:
-- SQL: SELECT customer.address.city FROM orders -- base column: customer -- fieldPath: ["address", "city"]
ColumnSource.getFieldPath()| Modifier and Type | Field and Description |
|---|---|
static FieldPath |
EMPTY
Empty field path singleton for regular column references
|
| Constructor and Description |
|---|
FieldPath(List<String> segments)
Create a FieldPath from a list of segments.
|
| Modifier and Type | Method and Description |
|---|---|
FieldPath |
append(FieldPath other)
Create a new FieldPath with additional segments appended.
|
FieldPath |
append(String segment)
Create a new FieldPath with an additional segment appended.
|
boolean |
equals(Object o) |
String |
get(int index)
Get a segment by index.
|
String |
getFirst()
Get the first segment (immediate field).
|
String |
getLast()
Get the last segment (deepest field).
|
List<String> |
getSegments()
Get the field path segments.
|
int |
hashCode() |
boolean |
isEmpty()
Check if this field path is empty (no field access).
|
static FieldPath |
of(List<String> segments)
Create a FieldPath from a list of segments.
|
static FieldPath |
of(String... segments)
Create a FieldPath from multiple segments.
|
static FieldPath |
of(String segment)
Create a FieldPath from a single segment.
|
int |
size()
Get the number of segments in this field path.
|
FieldPath |
subPath(int fromIndex)
Create a sub-path starting from the given index.
|
String |
toFullReference(String baseColumn)
Convert to full reference string with base column.
|
String |
toString()
Convert to dot-separated string representation.
|
public static FieldPath of(String segment)
segment - The single field segmentpublic static FieldPath of(String... segments)
segments - The field segmentspublic static FieldPath of(List<String> segments)
segments - The field segmentspublic List<String> getSegments()
public int size()
public boolean isEmpty()
public String getFirst()
public String getLast()
public String get(int index)
index - The indexIndexOutOfBoundsException - if index is invalidpublic FieldPath append(String segment)
segment - The segment to appendpublic FieldPath append(FieldPath other)
other - The FieldPath to appendpublic FieldPath subPath(int fromIndex)
fromIndex - Start index (inclusive)public String toFullReference(String baseColumn)
baseColumn - The base column name