@@ -23,7 +23,7 @@ PyODPS 对 MaxCompute 中的类型支持实现于 ``odps.types`` 包中。所有
23
23
通过字符串指定类型实例
24
24
~~~~~~~~~~~~~~~~~~~~~~
25
25
26
- 通常情况下,在 PyODPS 中,你都可以直接用 MaxCompute DDL 中表示类型的字符串来表示类型,这避免了 \
26
+ 通常情况下,在 PyODPS 中,你都可以直接用 MaxCompute DDL 中表示类型的字符串来表示类型,这可以避免 \
27
27
了解类型的实现细节。例如,当我们创建一个列实例,可以直接传入 ``array<int> `` 代表一个32位整数数组,\
28
28
而不需要关心使用哪个类去实现:
29
29
@@ -37,7 +37,7 @@ PyODPS 对 MaxCompute 中的类型支持实现于 ``odps.types`` 包中。所有
37
37
>> > print (type (column.type.value_type))
38
38
< class ' odps.types.Int' >
39
39
40
- 如果需要,你可以使用 :class: ` odps.types.validate_data_type ` 函数获取字符串表示的 MaxCompute 类型实例。
40
+ 如果需要,你可以使用 :func: ` ~ odps.types.validate_data_type ` 函数获取字符串表示的 MaxCompute 类型实例。
41
41
42
42
.. code-block :: python
43
43
@@ -194,7 +194,8 @@ MaxCompute 支持的复合类型有 Array、Map 和 Struct,可通过构造函
194
194
pt string # the partition
195
195
}
196
196
197
- 第二种方法是使用 ``TableSchema.from_lists `` 方法。这种方法更容易调用,但无法直接设置列和分区的注释。
197
+ 第二种方法是使用 :meth: `TableSchema.from_lists() <odps.models.TableSchema.from_lists> `
198
+ 方法。这种方法更容易调用,但无法直接设置列和分区的注释。
198
199
199
200
.. code-block :: python
200
201
@@ -213,9 +214,10 @@ MaxCompute 支持的复合类型有 Array、Map 和 Struct,可通过构造函
213
214
pt string
214
215
}
215
216
216
- 你可以从 ``TableSchema `` 实例中获取表的一般字段和分区字段。\ ``simple_columns `` 和 ``partitions ``
217
- 属性分别指代一般列和分区列,而 ``columns `` 属性则指代所有字段。这三个属性的返回值均为 :class: `~odps.types.Column `
218
- 或 :class: `~odps.types.Partition ` 类型组成的列表。你也可以通过 ``names `` 和 ``types `` 属性分别获取非分区字段的名称和类型。
217
+ 你可以从 :class: `~odps.models.TableSchema ` 实例中获取表的一般字段和分区字段。\ :attr: `~odps.models.TableSchema.simple_columns `
218
+ 和 :attr: `~odps.models.TableSchema.partitions ` 属性分别指代一般列和分区列,而 :attr: `~odps.models.TableSchema.columns `
219
+ 属性则指代所有字段。这三个属性的返回值均为 :class: `~odps.types.Column ` 或 :class: `~odps.types.Partition ` 类型组成的列表。\
220
+ 你也可以通过 ``names `` 和 ``types `` 属性分别获取非分区字段的名称和类型。
219
221
220
222
.. code-block :: python
221
223
@@ -242,9 +244,9 @@ MaxCompute 支持的复合类型有 Array、Map 和 Struct,可通过构造函
242
244
>> > print (schema.types) # 获取非分区字段的字段类型
243
245
[bigint, double]
244
246
245
- 在使用 `` TableSchema `` 时,:class: `~odps.types.Column ` 和 :class: `~odps.types.Partition ` 类型分别用于表示\
246
- 表的字段和分区 。你可以通过字段名和类型创建 `` Column `` 实例,也可以同时指定列注释以及字段是否可以为空。你也可以通过相应 \
247
- 的字段获取字段的名称 、类型等属性,其中类型为:ref: `数据类型 <data_types>`中的类型实例。
247
+ 在使用 :class: ` ~odps.models. TableSchema ` 时,:class: `~odps.types.Column ` 和 :class: `~odps.types.Partition `
248
+ 类型分别用于表示表的字段和分区 。你可以通过字段名和类型创建 :class: ` ~odps.types. Column ` 实例,也可以同时指定列注释以及字段是否可以为空。\
249
+ 你也可以通过相应的字段获取字段的名称 、类型等属性,其中类型为:ref: `数据类型 <data_types>`中的类型实例。
248
250
249
251
.. code-block :: python
250
252
@@ -264,14 +266,18 @@ MaxCompute 支持的复合类型有 Array、Map 和 Struct,可通过构造函
264
266
>> > print (col.nullable)
265
267
False
266
268
267
- 相比 `` Column `` 类型,\ `` Partition ` ` 类型仅仅是类名有差异,此处不再介绍。
269
+ 相比 :class: ` ~odps.types. Column ` 类型,\ :class: ` ~odps.types. Partition ` 类型仅仅是类名有差异,此处不再介绍。
268
270
269
271
.. _record-type :
270
272
271
273
行记录(Record)
272
274
----------------
273
- :class: `~odps.models.Record ` 类型表示表的一行记录,为 ``Table.open_reader `` / ``Table.open_writer `` 当 ``arrow=False ``
274
- 时所使用的数据结构,也用于 ``TableDownloadSession.open_record_reader `` / ``TableUploadSession.open_record_writer `` 。\
275
+ :class: `~odps.models.Record ` 类型表示表的一行记录,为
276
+ :meth: `Table.open_reader() <odps.models.Table.open_reader> ` /
277
+ :meth: `Table.open_reader() <odps.models.Table.open_writer> ` 当 ``arrow=False ``
278
+ 时所使用的数据结构,也用于
279
+ :meth: `TableDownloadSession.open_record_reader() <odps.tunnel.TableDownloadSession.open_record_reader> ` /
280
+ :meth: `TableUploadSession.open_record_writer() <odps.tunnel.TableUploadSession.open_record_writer> ` 。\
275
281
我们在 Table 对象上调用 new_record 就可以创建一个新的 Record。
276
282
277
283
下面的例子中,假定表结构为
0 commit comments