I am using 'rethinkdb import' to import a CSV file where one of the fields is a valid JSON object. However, it seems like RethinkDB is encoding this field as a string since I am unable to use nested filters to query the data set.
How do I specify the data type of each field at import time or modify the assumed data type after the import is finished?
From the documentation:
JSON files are preferred to CSV files, as JSON can represent RethinkDB documents fully. If you’re importing from a CSV file, you should include a header row with the field names, or use the --no-header option with the --custom-header option to specify the names.
rethinkdb import -f users.csv --format csv --table test.users --no-header \
--custom-header id,username,email,password
Values in CSV imports will always be imported as strings. If you want to convert those fields after import to the number data type, run an update query that does the conversion. An example runnable in the Data Explorer:
r.table('tablename').update(function(doc) {
return doc.merge({
field1: doc('field1').coerceTo('number'),
field2: doc('field2').coerceTo('number')
})
});