You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The DataStax keyspace name is `stocks_keyspace`. In the stocks keyspace create the user defined type, `stocks_type`:
52
54
53
55
[source,language-cql]
@@ -59,7 +61,6 @@ CREATE TYPE stocks_keyspace.stocks_type (
59
61
industry text,
60
62
value double);
61
63
----
62
-
|===
63
64
64
65
Define a table named `stocks_udt_table` that has a column for the primitive string field `name` and a second column that uses the type, `stocks_type`:
65
66
@@ -80,3 +81,49 @@ topic:
80
81
stocks_udt_table:
81
82
mapping: 'name=key,stocks=value'
82
83
----
84
+
85
+
== Mapping complex user defined types
86
+
87
+
The DataStax Apache Pulsar™ Connector supports mapping complex user defined types of `map`, `set`, and `list`.
88
+
89
+
The DataStax keyspace name is `stocks_keyspace`. In the stocks keyspace create the user defined type, `stocks_complex_type`:
90
+
91
+
[source,language-cql]
92
+
----
93
+
CREATE TYPE stocks_keyspace.stocks_complex_type (
94
+
symbol text,
95
+
ts timestamp,
96
+
exchange text,
97
+
industry text,
98
+
value double,
99
+
trailing_five_days_value frozen<list<double>>,
100
+
similar_symbols frozen<set<text>>,
101
+
stats frozen<map<text, double>>);
102
+
----
103
+
104
+
* `trailing_five_days_value frozen<list<double>>` contains a `list` of the value of the stock in the last five days, for example `[10.0, 11.0, 12.0, 23.0, 10.0]`. Values in a list do not need to be unique.
105
+
* `similar_symbols frozen<set<text>>` contains a `set` of symbols in the same industry, or performing similarly, for example `["M", "GM", "F"]`. Values in a set must be unique.
106
+
* `stats frozen<map<text, double>>` contains a `map` of key-value pairs, for example `{"open": 11.0, "high": 20.0, "low": 9.0}`.
107
+
108
+
Define a table named `stocks_complex_udt_table` that has a column for the primitive string field `name` and a second column that uses the type, `stocks_complex_type`:
0 commit comments