Record Class SourceDeclaration

java.lang.Object
java.lang.Record
com.darkcollective.relix.lang.ast.SourceDeclaration
Record Components:
exported - true if the source is importable by other files
name - the relation name; must not be blank
config - the transport and schema configuration; must not be null
location - the source location of this statement; never null
All Implemented Interfaces:
Statement

public record SourceDeclaration(boolean exported, String name, SourceConfig config, SourceLocation location) extends Record implements Statement
A source declaration — names a virtual relation backed by an external data source.

Syntax:

   source current_weather from http {
       url:    "https://api.example.com/weather",
       method: GET,
       headers: { "X-API-Key": "${WEATHER_API_KEY}" },
       extract: json("$."),
       schema: {
           city: in  STRING as query("q") [required],
           temp: out NUMBER at "$.main.temp"
       }
   };
 

Multiple source declarations with the same name() but different in-column sets represent overloads of the same virtual relation — the query planner selects the overload whose required parameters are satisfied by equality predicates in the query.

The exported flag is false when the declaration is prefixed with private — the source is usable within the file but not importable by other files.

  • Constructor Details

    • SourceDeclaration

      public SourceDeclaration(boolean exported, String name, SourceConfig config, SourceLocation location)
      Creates an instance of a SourceDeclaration record class.
      Parameters:
      exported - the value for the exported record component
      name - the value for the name record component
      config - the value for the config record component
      location - the value for the location record component
    • SourceDeclaration

      public SourceDeclaration(boolean exported, String name, SourceConfig config)
      Convenience constructor for tests; uses SourceLocation.UNKNOWN.
  • Method Details

    • of

      public static SourceDeclaration of(String name, SourceConfig config)
      Creates an exported source declaration (the common case).
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • exported

      public boolean exported()
      Returns the value of the exported record component.
      Returns:
      the value of the exported record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • config

      public SourceConfig config()
      Returns the value of the config record component.
      Returns:
      the value of the config record component
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Specified by:
      location in interface Statement
      Returns:
      the value of the location record component