使用实木复合地板查询示例 - Amazon Neptune
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用实木复合地板查询示例

以下示例查询返回给定 Parquet 文件中的行数:

CALL neptune.read( { source: "<s3 path>", format: "parquet" } ) YIELD row RETURN count(row)

您可以通过执行以下代码,使用中的execute-open-cypher-query操作 Amazon CLI 来运行查询示例:

aws neptunedata execute-open-cypher-query \ --open-cypher-query "CALL neptune.read({source: '<s3 path>', format: 'parquet'}) YIELD row RETURN count(row)" \ --endpoint-url https://my-cluster-name.cluster-abcdefgh1234.us-east-1.neptune.amazonaws.com:8182

查询可以灵活地处理从 Parquet 文件中读取的行。例如,以下查询创建一个节点,其字段设置为在 Parquet 文件中找到的数据:

CALL neptune.read( { source: "<s3 path>", format: "parquet" } ) YIELD row CREATE (n {someField: row.someCol}) RETURN n
警告

使用像条款MATCH(n)之前那样的大型产生结果的条款不被视为良好做法。CALL这将导致查询长时间运行,这是因为来自先前子句的传入解决方案与 neptune.read 读取的行之间存在交叉积。建议使用 nept CALL une.read 开始查询。

支持的镶木地板柱类型

实木复合地板数据类型:

  • NULL

  • BOOLEAN

  • FLOAT

  • DOUBLE

  • string

  • 有符号整数: UINT8、 UINT16、 UINT32、 UINT64

  • 地图:仅支持一级。不支持嵌套。

  • 列表:仅支持一级。不支持嵌套。

海王星特定的数据类型:

与 CSV 格式的属性列标题不同,Parquet 格式的属性列标题只需要具有属性名称,因此无需输入类型名称或基数。

但是,有些特殊的 Parquet 格式列类型需要在元数据中进行注释,包括 “任意类型”、“日期类型”、“日期时间” 类型和 “几何类型”。以下对象是包含这些特殊类型列的文件所需的元数据注释的示例:

"metadata": { "anyTypeColumns": ["UserCol1"], "dateTypeColumns": ["UserCol2"], "dateTimeTypeColumns": ["UserCol3"], "geometryTypeColumns": ["UserCol4"] }

以下是与这些类型相关的预期有效载荷的详细信息:

  • 用户列中支持 “任意” 列类型。Any 类型是我们支持的所有其他类型的 “句法糖” 类型。如果用户列中有多种类型,则它非常有用。Any type 值的有效负载是一个 json 字符串列表,如下所示:{"value": "10", "type": "Int"};{"value": "1.0", "type": "Float"},它在每个 json 字符串中都有一个值字段和一个类型字段。已设置 “任意” 列的基数值,这意味着该列可以接受多个值。

    • Neptune 在 Any 类型中支持以下类型:布尔型(或布尔型)、字节、短整型、长整型、、、、、 UnsignedByte UnsignedShort、浮点型 UnsignedInt UnsignedLong、双精度、日期、日期时间、日期时间、字符串和几何。

    • 任何类型都不支持向量类型。

    • 嵌套不支持任何类型。例如 {"value": {"value": "10", "type": "Int"}, "type": "Any"}

  • 用户列中支持日期和日期时间类型的列。这些列的有效负载必须以符合 XSD 格式或以下格式之一的字符串形式提供:

    • yyyy-MM-dd

    • yyyy-mm-ddthh: mm

    • yyyy-mm-ddthh: mm: ss

    • yyyy-mm-ddthh: mm: ssz

    • yyyy-mm-ddthh: mm: ss.sssz

    • yyyy-mm-ddthh: mm: ss [+|-] 嗯嗯

    • yyyy-mm-ddthh: mm: ss.sss [+|-] 嗯嗯

  • 用户列支持几何列类型。这些列的有效载荷只能包含 Point 类型的几何基元,这些基元以众所周知文本 (WKT) 格式的字符串形式提供。例如,点 (30 10) 将是有效的几何值。

镶木地板输出示例

给定这样的 Parquet 文件:

<s3 path> Parquet Type: int8 int16 int32 int64 float double string +--------+---------+-------------+----------------------+------------+------------+----------+ | Byte | Short | Int | Long | Float | Double | String | |--------+---------+-------------+----------------------+------------+------------+----------| | -128 | -32768 | -2147483648 | -9223372036854775808 | 1.23456 | 1.23457 | first | | 127 | 32767 | 2147483647 | 9223372036854775807 | nan | nan | second | | 0 | 0 | 0 | 0 | -inf | -inf | third | | 0 | 0 | 0 | 0 | inf | inf | fourth | +--------+---------+-------------+----------------------+------------+------------+----------+

以下是 neptune.read 使用以下查询返回的输出示例:

aws neptunedata execute-open-cypher-query \ --open-cypher-query "CALL neptune.read({source: '<s3 path>', format: 'parquet'}) YIELD row RETURN row" \ --endpoint-url https://my-cluster-name.cluster-abcdefgh1234.us-east-1.neptune.amazonaws.com:8182
{ "results": [{ "row": { "Float": 1.23456, "Byte": -128, "Int": -2147483648, "Long": -9223372036854775808, "String": "first", "Short": -32768, "Double": 1.2345678899999999 } }, { "row": { "Float": "NaN", "Byte": 127, "Int": 2147483647, "Long": 9223372036854775807, "String": "second", "Short": 32767, "Double": "NaN" } }, { "row": { "Float": "-INF", "Byte": 0, "Int": 0, "Long": 0, "String": "third", "Short": 0, "Double": "-INF" } }, { "row": { "Float": "INF", "Byte": 0, "Int": 0, "Long": 0, "String": "fourth", "Short": 0, "Double": "INF" } }] }

当前,无法为来自 Parquet 文件的数据字段设置节点或边缘标签。建议您将查询分成多个查询,每个查询对应一个标签/类型。

CALL neptune.read({source: '<s3 path>', format: 'parquet'}) YIELD row WHERE row.`~label` = 'airport' CREATE (n:airport) CALL neptune.read({source: '<s3 path>', format: 'parquet'}) YIELD row WHERE row.`~label` = 'country' CREATE (n:country)