예제 #1
0
def test_repr_struct_of_array_of_struct():
    param = ibis.param('struct<x: array<struct<y: array<double>>>>')
    param = param.name('foo')
    value = collections.OrderedDict([
        (
            'x',
            [
                collections.OrderedDict([
                    ('y', [1.0, 2.0, 3.0])
                ])
            ]
        )
    ])
    result = bigquery_param(param, value)
    expected = {
        'name': 'foo',
        'parameterType': {
            'structTypes': [
                {
                    'name': 'x',
                    'type': {
                        'arrayType': {
                            'structTypes': [
                                {
                                    'name': 'y',
                                    'type': {
                                        'arrayType': {'type': 'FLOAT64'},
                                        'type': 'ARRAY'
                                    }
                                }
                            ],
                            'type': 'STRUCT'
                        },
                        'type': 'ARRAY'
                    }
                }
            ],
            'type': 'STRUCT'
        },
        'parameterValue': {
            'structValues': {
                'x': {
                    'arrayValues': [
                        {
                            'structValues': {
                                'y': {
                                    'arrayValues': [
                                        {'value': 1.0},
                                        {'value': 2.0},
                                        {'value': 3.0}
                                    ]
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
    assert result.to_api_repr() == expected
예제 #2
0
def test_repr_struct_of_array_of_struct():
    param = ibis.param('struct<x: array<struct<y: array<double>>>>')
    param = param.name('foo')
    value = collections.OrderedDict(
        [('x', [collections.OrderedDict([('y', [1.0, 2.0, 3.0])])])]
    )
    result = bigquery_param(param, value)
    expected = {
        'name': 'foo',
        'parameterType': {
            'structTypes': [
                {
                    'name': 'x',
                    'type': {
                        'arrayType': {
                            'structTypes': [
                                {
                                    'name': 'y',
                                    'type': {
                                        'arrayType': {'type': 'FLOAT64'},
                                        'type': 'ARRAY',
                                    },
                                }
                            ],
                            'type': 'STRUCT',
                        },
                        'type': 'ARRAY',
                    },
                }
            ],
            'type': 'STRUCT',
        },
        'parameterValue': {
            'structValues': {
                'x': {
                    'arrayValues': [
                        {
                            'structValues': {
                                'y': {
                                    'arrayValues': [
                                        {'value': 1.0},
                                        {'value': 2.0},
                                        {'value': 3.0},
                                    ]
                                }
                            }
                        }
                    ]
                }
            }
        },
    }
    assert result.to_api_repr() == expected