MCPcopy Create free account
hub / github.com/apache/impala / Column

Class Column

tests/comparison/common.py:245–296  ·  view source on GitHub ↗

A representation of a column. All TableExprs will have Columns. So a Column may belong to an InlineView as well as a standard Table. This class is used in two ways: 1) As a piece of metadata in a table definiton. In this usage the col isn't intended to represent an val.

Source from the content-addressed store, hash-verified

243
244
245class Column(ValExpr):
246 '''A representation of a column. All TableExprs will have Columns. So a Column
247 may belong to an InlineView as well as a standard Table.
248
249 This class is used in two ways:
250
251 1) As a piece of metadata in a table definiton. In this usage the col isn't
252 intended to represent an val.
253
254 2) As an expr in a query, for example an item being selected or as part of
255 a JOIN condition. In this usage the col is more like a val, which is why
256 it implements/extends ValExpr.
257
258 This class can also be used to represent Map keys, Map values, Array pos,
259 scalar struct field, and scalar array item.
260 '''
261
262 def __init__(self, owner, name, exact_type):
263 self.owner = owner
264 self.name = name
265 self._exact_type = exact_type
266 self.is_primary_key = False
267
268 @property
269 def exact_type(self):
270 return self._exact_type
271
272 @exact_type.setter
273 def exact_type(self, exact_type):
274 self._exact_type = exact_type
275
276 def __hash__(self):
277 return hash(self.name)
278
279 def __eq__(self, other):
280 if not isinstance(other, Column):
281 return False
282 if self is other:
283 return True
284 return self.name == other.name and self.owner.identifier == other.owner.identifier
285
286 @property
287 def cols(self):
288 return ValExprList([self])
289
290 def __repr__(self):
291 return '%s<name: %s, type: %s>' % (
292 type(self).__name__, self.name, self.exact_type.__name__)
293
294 def __deepcopy__(self, memo):
295 # Don't return a deep copy of owner, since that is a circular reference
296 return Column(self.owner, self.name, self.exact_type)
297
298
299class ValExprList(list):

Callers 12

_create_random_tableMethod · 0.90
create_join_predicateMethod · 0.90
create_columnMethod · 0.90
describe_tableMethod · 0.90
colsMethod · 0.90
FakeColumnFunction · 0.90
test_table_modelMethod · 0.90
__deepcopy__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by 3

test_table_modelMethod · 0.72