Skip to content

Commit

Permalink
SNOW-1794359:[API Coverage] MapType (#2636)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-yuwang authored Nov 18, 2024
1 parent 8976902 commit d4b03af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- `simple_string`
- `json_value`
- `json`
- Added support for variables `keyType` and `valueType` in class `MapType`

#### Improvements

Expand Down
8 changes: 8 additions & 0 deletions src/snowflake/snowpark/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ def json_value(self) -> Dict[str, Any]:
"value_type": self.value_type.json_value(),
}

@property
def keyType(self):
return self.key_type

@property
def valueType(self):
return self.value_type

simpleString = simple_string
jsonValue = json_value

Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1234,3 +1234,14 @@ def test_datatype(tpe, simple_string, json, type_name, json_value):
tpe.typeName()
else:
assert tpe.typeName() == type_name


def test_maptype_alias():
expected_key = StringType()
expected_value = IntegerType()
tpe = MapType(expected_key, expected_value)
assert tpe.valueType == expected_value
assert tpe.keyType == expected_key

assert tpe.valueType == tpe.value_type
assert tpe.keyType == tpe.key_type

0 comments on commit d4b03af

Please sign in to comment.