Skip to content

too many values for field - { type: 'array', items: [ { type: 'number' }] } #154

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

Open
helxsz opened this issue Jan 17, 2025 · 2 comments
Open

Comments

@helxsz
Copy link

helxsz commented Jan 17, 2025

my json schema is as followed

{
  type: 'object',
  properties: {
    coordinate: { type: 'array', items: [ { type: 'number' }] },
    report_year: { type: 'string', format: 'date-time' }
  }
}
const writeParquet = async ( jsonschema:any, dataList:any[], filename:string) => {
  const parquetSchema =  ParquetSchema.fromJsonSchema(jsonschema);
  const parquetPath = join(process.cwd(), 'temp', filename );
  const writer = await ParquetWriter.openFile(parquetSchema, parquetPath);
  dataList.forEach(async item => {
    try{
      await writer.appendRow(item);
    }catch(err){
      console.log(err);
    }
  });
  await writer.close();
  return parquetPath;
}

let dataitem = {
    coordinate: [ 119.602407407407, 29.9779320987654 ],
    report_year: '2020-12-31T16:00:00.000Z',
}
let parquetPath =  writeParquet( jsonschema, [dataitem],  'afd.parquet' );

but I got an error saying 'too many values for field: coordinate'.

any idea how to deal with it?

@cjkeilig
Copy link

I saw the example in the code base, for coordinate it could be { type: 'FLOAT', repeated: true }

@helxsz
Copy link
Author

helxsz commented Feb 5, 2025

thanks, @cjkeilig , yes, it is all right to work with { type: 'FLOAT', repeated: true }. But in my case, we don't declare the native schema directly but declare the json schema.

it seems if I pass the json schema with a array like this coordinate: { type: 'array', items: [ { type: 'number' }] }, it will throw out an exception like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants