Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra] Falha no load de tabelas em formato Avro para o BQ #1252

Open
lucascr91 opened this issue Jun 27, 2022 · 0 comments
Open

[infra] Falha no load de tabelas em formato Avro para o BQ #1252

lucascr91 opened this issue Jun 27, 2022 · 0 comments
Assignees
Labels
bug Something isn't working hacktoberfest

Comments

@lucascr91
Copy link
Collaborator

lucascr91 commented Jun 27, 2022

Aparentemente, o load de tabelas externas no formato avro para o BQ não está funcionando. Para replicar o erro, basta rodar:

    table = bd.Table("ds_test", "tb_test")
    table.create(
        path='mais/python-package/tests/sample_data/table/municipio.avro',
        if_table_exists="replace",
        if_storage_data_exists="pass",
        if_table_config_exists="replace",
        source_format="avro",
    )

Que gera o seguinte erro:

The Apache Avro library failed to parse the header with the following error: Invalid data file. Magic does not match: bigstore/basedosdados-dev/staging/ds_test/tb_test/municipio.parquet

Creio que este problema e o problema do upload de dados em Parquet, relatado na issue #1158, podem estar ocorrendo em função da relativa ausência de configuração da tabela externa, na definição de external_config para esses dois formatos:

def external_config(self):
        '''
        Configure the external table
        '''
        if self.source_format == "csv":
            _external_config = bigquery.ExternalConfig("CSV")
            _external_config.options.skip_leading_rows = 1
            _external_config.options.allow_quoted_newlines = True
            _external_config.options.allow_jagged_rows = True
            _external_config.autodetect = False
            _external_config.schema = self.table_obj._load_schema(self.mode)
        elif self.source_format == "avro":
            _external_config = bigquery.ExternalConfig("AVRO")
        elif self.source_format == "parquet":
            _external_config = bigquery.ExternalConfig("PARQUET")
        else:
...

No entanto, ao menos por ora, não está claro para mim quais configuraçõees devem ser adicionadas para que o upload em ambos os formatos ocorram de forma correta. Como tentativa inicial, tentei subir os dados em avro adicionando explicitamente o schema, mas obtive o mesmo erro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants