77package org .elasticsearch .xpack .esql .core .expression ;
88
99import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
10- import org .elasticsearch .core .Tuple ;
1110import org .elasticsearch .xpack .esql .core .tree .Source ;
1211import org .elasticsearch .xpack .esql .core .type .DataType ;
1312
1413import java .util .List ;
1514import java .util .Objects ;
1615
1716import static java .util .Collections .emptyList ;
18- import static org .elasticsearch .xpack .esql .core .util .StringUtils .splitQualifiedIndex ;
1917
2018/**
2119 * {@link Expression}s that can be materialized and describe properties of the derived table.
@@ -35,33 +33,19 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
3533 return List .of (FieldAttribute .ENTRY , MetadataAttribute .ENTRY , ReferenceAttribute .ENTRY );
3634 }
3735
38- // empty - such as a top level attribute in SELECT cause
39- // present - table name or a table name alias
40- private final String qualifier ;
41- // cluster name in the qualifier (if any)
42- private final String cluster ;
43-
4436 // can the attr be null - typically used in JOINs
4537 private final Nullability nullability ;
4638
47- public Attribute (Source source , String name , String qualifier , NameId id ) {
48- this (source , name , qualifier , Nullability .TRUE , id );
39+ public Attribute (Source source , String name , NameId id ) {
40+ this (source , name , Nullability .TRUE , id );
4941 }
5042
51- public Attribute (Source source , String name , String qualifier , Nullability nullability , NameId id ) {
52- this (source , name , qualifier , nullability , id , false );
43+ public Attribute (Source source , String name , Nullability nullability , NameId id ) {
44+ this (source , name , nullability , id , false );
5345 }
5446
55- public Attribute (Source source , String name , String qualifier , Nullability nullability , NameId id , boolean synthetic ) {
47+ public Attribute (Source source , String name , Nullability nullability , NameId id , boolean synthetic ) {
5648 super (source , name , emptyList (), id , synthetic );
57- if (qualifier != null ) {
58- Tuple <String , String > splitQualifier = splitQualifiedIndex (qualifier );
59- this .cluster = splitQualifier .v1 ();
60- this .qualifier = splitQualifier .v2 ();
61- } else {
62- this .cluster = null ;
63- this .qualifier = null ;
64- }
6549 this .nullability = nullability ;
6650 }
6751
@@ -70,14 +54,6 @@ public final Expression replaceChildren(List<Expression> newChildren) {
7054 throw new UnsupportedOperationException ("this type of node doesn't have any children to replace" );
7155 }
7256
73- public String qualifier () {
74- return qualifier ;
75- }
76-
77- public String qualifiedName () {
78- return qualifier == null ? name () : qualifier + "." + name ();
79- }
80-
8157 @ Override
8258 public Nullability nullable () {
8359 return nullability ;
@@ -89,42 +65,26 @@ public AttributeSet references() {
8965 }
9066
9167 public Attribute withLocation (Source source ) {
92- return Objects .equals (source (), source ) ? this : clone (source , name (), dataType (), qualifier (), nullable (), id (), synthetic ());
93- }
94-
95- public Attribute withQualifier (String qualifier ) {
96- return Objects .equals (qualifier (), qualifier )
97- ? this
98- : clone (source (), name (), dataType (), qualifier , nullable (), id (), synthetic ());
68+ return Objects .equals (source (), source ) ? this : clone (source , name (), dataType (), nullable (), id (), synthetic ());
9969 }
10070
10171 public Attribute withName (String name ) {
102- return Objects .equals (name (), name ) ? this : clone (source (), name , dataType (), qualifier (), nullable (), id (), synthetic ());
72+ return Objects .equals (name (), name ) ? this : clone (source (), name , dataType (), nullable (), id (), synthetic ());
10373 }
10474
10575 public Attribute withNullability (Nullability nullability ) {
106- return Objects .equals (nullable (), nullability )
107- ? this
108- : clone (source (), name (), dataType (), qualifier (), nullability , id (), synthetic ());
76+ return Objects .equals (nullable (), nullability ) ? this : clone (source (), name (), dataType (), nullability , id (), synthetic ());
10977 }
11078
11179 public Attribute withId (NameId id ) {
112- return clone (source (), name (), dataType (), qualifier (), nullable (), id , synthetic ());
80+ return clone (source (), name (), dataType (), nullable (), id , synthetic ());
11381 }
11482
11583 public Attribute withDataType (DataType type ) {
116- return Objects .equals (dataType (), type ) ? this : clone (source (), name (), type , qualifier (), nullable (), id (), synthetic ());
84+ return Objects .equals (dataType (), type ) ? this : clone (source (), name (), type , nullable (), id (), synthetic ());
11785 }
11886
119- protected abstract Attribute clone (
120- Source source ,
121- String name ,
122- DataType type ,
123- String qualifier ,
124- Nullability nullability ,
125- NameId id ,
126- boolean synthetic
127- );
87+ protected abstract Attribute clone (Source source , String name , DataType type , Nullability nullability , NameId id , boolean synthetic );
12888
12989 @ Override
13090 public Attribute toAttribute () {
@@ -143,27 +103,27 @@ public boolean semanticEquals(Expression other) {
143103
144104 @ Override
145105 protected Expression canonicalize () {
146- return clone (Source .EMPTY , name (), dataType (), qualifier , nullability , id (), synthetic ());
106+ return clone (Source .EMPTY , name (), dataType (), nullability , id (), synthetic ());
147107 }
148108
149109 @ Override
150110 public int hashCode () {
151- return Objects .hash (super .hashCode (), qualifier , nullability );
111+ return Objects .hash (super .hashCode (), nullability );
152112 }
153113
154114 @ Override
155115 public boolean equals (Object obj ) {
156116 if (super .equals (obj )) {
157117 Attribute other = (Attribute ) obj ;
158- return Objects .equals (qualifier , other . qualifier ) && Objects . equals ( nullability , other .nullability );
118+ return Objects .equals (nullability , other .nullability );
159119 }
160120
161121 return false ;
162122 }
163123
164124 @ Override
165125 public String toString () {
166- return qualifiedName () + "{" + label () + "}" + "#" + id ();
126+ return name () + "{" + label () + "}" + "#" + id ();
167127 }
168128
169129 @ Override
0 commit comments