usql icon indicating copy to clipboard operation
usql copied to clipboard

AvroExtractor makes new row for each column

Open vaerge opened this issue 8 years ago • 3 comments

I am wondering why the AvroExtractor is made to make a new row for each new column, and not a new row after all columns for that object have been read. See my comment in code snippet below, from AvroExtractor.cs

while (fileReader.HasNext())
{
	var avroRecord = fileReader.Next();

	foreach (var column in output.Schema)
	{
		if (avroRecord[column.Name] != null)
		{
			output.Set(column.Name, avroRecord[column.Name]);
		}
		else
		{
			output.Set<object>(column.Name, null);
		}

		yield return output.AsReadOnly(); // Why here, and not after the foreach loop?
	}
}

Consequence is that the output looks like this:

City   Country   Phone
NY   
           US   
                       345
QD   
           CH   
                       948

instead of

City   Country   Phone
NY      US          345
QD     CH          948

There's probably a purpose with the current way, but I don't quite understand it - so if someone could enlighten me, it would be greatly appreciated!

vaerge avatar Oct 19 '17 07:10 vaerge

I made a pull request on this

vaerge avatar Oct 19 '17 07:10 vaerge

Adding @flomader. I guess that was an oversight.

MikeRys avatar Oct 20 '17 08:10 MikeRys

That's a bug. Thanks for finding and fixing.

flomader-zz avatar Oct 20 '17 08:10 flomader-zz