Skip to content

Commit f798f4a

Browse files
committed
Pre-releases v0.12.3rc1 (#276)(#277)(#278)(#279)
1 parent cef7539 commit f798f4a

File tree

20 files changed

+504
-268
lines changed

20 files changed

+504
-268
lines changed

docs/source/base-instances.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Task如SQLTask是ODPS的基本计算单元,当一个Task在执行时会被实
6161
-------------
6262

6363
一个instance的状态可以是 ``Running``、``Suspended`` 或者 ``Terminated``,用户可以通过
64-
:meth:`~odps.models.Instance.status` 属性来获取状态。:meth:`~odps.models.Instance.is_terminated`
64+
:attr:`~odps.models.Instance.status` 属性来获取状态。:meth:`~odps.models.Instance.is_terminated`
6565
方法返回当前instance是否已经执行完成,:meth:`~odps.models.Instance.is_successful`
6666
方法返回当前instance是否正确完成执行,任务处于运行中或者执行失败都会返回False。
6767

docs/source/base-tables.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ PyODPS 0.11.5 及后续版本中,可以为 :meth:`~odps.ODPS.list_tables` 添
139139
>>> table = o.create_table('my_new_table', 'cat smallint, content struct<title:varchar(100), body string>')
140140
141141
:meth:`~odps.ODPS.create_table` 方法也提供了其他参数,可用于设置表属性及事务性等参数。例如,下面的调用创建了一张
142-
ACID 2.0 表并指定 ``key`` 为主键。
142+
ACID 2.0 表并指定 ``key`` 为主键(``key``必须指定为非空)
143143
144144
.. code-block:: python
145145
146-
>>> table = o.create_table('my_trans_table', 'key string, value string',
146+
>>> table = o.create_table('my_trans_table', 'key string not null, value string',
147147
>>> primary_key=['key'], transactional=True)
148148
149149
@@ -324,12 +324,13 @@ DataFrame,并通过 ``batch_size`` 参数指定每次读取的 DataFrame 批
324324
325325
.. note::
326326

327-
**注意**\ :每次调用 write_table,MaxCompute 都会在服务端生成一个文件。这一操作需要较大的时间开销,\
328-
同时过多的文件会降低后续的查询效率。因此,我们建议在使用 write_table 方法时,一次性写入多组数据,\
329-
或者传入一个 generator 对象。
327+
**注意**\ :每次调用 :meth:`~odps.ODPS.write_table`,MaxCompute 都会在服务端生成一个文件。\
328+
这一操作需要较大的时间开销,同时过多的文件会降低后续的查询效率。因此,我们建议在使用
329+
:meth:`~odps.ODPS.write_table` 方法时,一次性写入多组数据,或者传入一个 generator 对象。
330330

331-
write_table 写表时会追加到原有数据。如果需要覆盖数据,可以为 write_table 增加一个参数 ``overwrite=True``
332-
(仅在 0.11.1 以后支持),或者调用 table.truncate() / 删除分区后再建立分区。
331+
:meth:`~odps.ODPS.write_table` 写表时会追加到原有数据。如果需要覆盖数据,可以为 :meth:`~odps.ODPS.write_table`
332+
增加一个参数 ``overwrite=True``(仅在 0.11.1 以后支持),或者调用 :meth:`Table.truncate() <odps.models.Table.truncate>`
333+
/ 删除分区后再建立分区。
333334
334335
你可以使用多线程写入数据。从 PyODPS 0.11.6 开始,直接将 open_writer 创建的 Writer 对象分发到\
335336
各个线程中即可完成多线程写入,写入时请注意不要关闭 writer,待所有数据写入完成后再关闭 writer。
@@ -393,8 +394,8 @@ open_writer 创建的 Writer 对象通过 multiprocessing 标准库传递到需
393394
# 等待子进程中的执行完成
394395
[f.get() for f in futures]
395396
396-
从 0.11.2 开始,PyODPS 支持使用 `Arrow <https://arrow.apache.org/>`_ 格式读写数据,该格式可以以更高\
397-
效率与 pandas 等格式互相转换。安装 pyarrow 后,在调用 ``open_writer`` 时增加 ``arrow=True`` 参数,即可按
397+
从 0.11.2 开始,PyODPS 支持使用 `Arrow <https://arrow.apache.org/>`_ 格式读写数据,该格式可以以更高效率与
398+
pandas 等格式互相转换。安装 pyarrow 后,在调用 ``open_writer`` 时增加 ``arrow=True`` 参数,即可按
398399
`Arrow RecordBatch <https://arrow.apache.org/docs/python/data.html#record-batches>`_
399400
格式写入表内容。PyODPS 也支持直接写入 pandas DataFrame,支持自动转换为 Arrow RecordBatch。
400401

docs/source/base-types.rst

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PyODPS 对 MaxCompute 中的类型支持实现于 ``odps.types`` 包中。所有
2323
通过字符串指定类型实例
2424
~~~~~~~~~~~~~~~~~~~~~~
2525

26-
通常情况下,在 PyODPS 中,你都可以直接用 MaxCompute DDL 中表示类型的字符串来表示类型,这避免了\
26+
通常情况下,在 PyODPS 中,你都可以直接用 MaxCompute DDL 中表示类型的字符串来表示类型,这可以避免\
2727
了解类型的实现细节。例如,当我们创建一个列实例,可以直接传入 ``array<int>`` 代表一个32位整数数组,\
2828
而不需要关心使用哪个类去实现:
2929

@@ -37,7 +37,7 @@ PyODPS 对 MaxCompute 中的类型支持实现于 ``odps.types`` 包中。所有
3737
>>> print(type(column.type.value_type))
3838
<class 'odps.types.Int'>
3939
40-
如果需要,你可以使用 :class:`odps.types.validate_data_type` 函数获取字符串表示的 MaxCompute 类型实例。
40+
如果需要,你可以使用 :func:`~odps.types.validate_data_type` 函数获取字符串表示的 MaxCompute 类型实例。
4141

4242
.. code-block:: python
4343
@@ -194,7 +194,8 @@ MaxCompute 支持的复合类型有 Array、Map 和 Struct,可通过构造函
194194
pt string # the partition
195195
}
196196
197-
第二种方法是使用 ``TableSchema.from_lists`` 方法。这种方法更容易调用,但无法直接设置列和分区的注释。
197+
第二种方法是使用 :meth:`TableSchema.from_lists() <odps.models.TableSchema.from_lists>`
198+
方法。这种方法更容易调用,但无法直接设置列和分区的注释。
198199

199200
.. code-block:: python
200201
@@ -213,9 +214,10 @@ MaxCompute 支持的复合类型有 Array、Map 和 Struct,可通过构造函
213214
pt string
214215
}
215216
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`` 属性分别获取非分区字段的名称和类型。
219221

220222
.. code-block:: python
221223
@@ -242,9 +244,9 @@ MaxCompute 支持的复合类型有 Array、Map 和 Struct,可通过构造函
242244
>>> print(schema.types) # 获取非分区字段的字段类型
243245
[bigint, double]
244246
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>`中的类型实例。
248250

249251
.. code-block:: python
250252
@@ -264,14 +266,18 @@ MaxCompute 支持的复合类型有 Array、Map 和 Struct,可通过构造函
264266
>>> print(col.nullable)
265267
False
266268
267-
相比 ``Column`` 类型,\ ``Partition`` 类型仅仅是类名有差异,此处不再介绍。
269+
相比 :class:`~odps.types.Column` 类型,\ :class:`~odps.types.Partition` 类型仅仅是类名有差异,此处不再介绍。
268270

269271
.. _record-type:
270272

271273
行记录(Record)
272274
----------------
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>` 。\
275281
我们在 Table 对象上调用 new_record 就可以创建一个新的 Record。
276282

277283
下面的例子中,假定表结构为

docs/source/locale/en/LC_MESSAGES/base-instances.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PyODPS 0.7.16\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2025-04-17 11:44+0800\n"
11+
"POT-Creation-Date: 2025-04-19 21:33+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -133,14 +133,14 @@ msgstr "Instance status"
133133
#: ../../source/base-instances.rst:63
134134
msgid ""
135135
"一个instance的状态可以是 ``Running``、``Suspended`` 或者 ``Terminated``,"
136-
"用户可以通过 :meth:`~odps.models.Instance.status` 属性来获取状态。:meth:`"
136+
"用户可以通过 :attr:`~odps.models.Instance.status` 属性来获取状态。:meth:`"
137137
"~odps.models.Instance.is_terminated` 方法返回当前instance是否已经执行完成"
138138
",:meth:`~odps.models.Instance.is_successful` 方法返回当前instance是否"
139139
"正确完成执行,任务处于运行中或者执行失败都会返回False。"
140140
msgstr ""
141141
"The status of an instance can be ``Running``, ``Suspended`` or "
142142
"``Terminated``. You can retrieve the status of an instance by using the "
143-
":meth:`~odps.models.Instance.status` attribute. The "
143+
":attr:`~odps.models.Instance.status` attribute. The "
144144
":meth:`~odps.models.Instance.is_terminated` method returns whether the "
145145
"execution of the current instance has been completed. The "
146146
":meth:`~odps.models.Instance.is_successful` method returns whether the "

0 commit comments

Comments
 (0)