I am new to avro and while trying to use avro alias property i am getting below error.
Query : select department_id , office_name from test.depart_alias;
SemanticException [Error 10004]: Line 1:23 Invalid table alias or column reference 'office_name': (possible column names are: department_id, department_name)
My json file for avsc format is
{
  "type" : "record",
  "name" : "departments",
  "doc" : "Sqoop import of departments",
  "fields" : [ {
    "name" : "department_id",
    "type" : [ "null", "int" ],
    "default" : null,
    "columnName" : "department_id",
    "sqlType" : "4"
  }, {
    "name" : "department_name",
    "type" : [ "null", "string" ],
    "default" : null,
    "aliases" : [ "office_name" ],
    "columnName" : "department_name",
    "sqlType" : "12"
  } ],
  "tableName" : "departments"
I want to use office name as alias to department_name. How should i implement it
Thanks
if your old column field is named department_name your schema should looks like this
{
  "type" : "record",
  "name" : "departments",
  "doc" : "Sqoop import of departments",
  "fields" : [ {
    "name" : "department_id",
    "type" : [ "null", "int" ],
    "default" : null,
    "columnName" : "department_id",
    "sqlType" : "4"
  }, {
    "name" : "office_name",
    "type" : [ "null", "string" ],
    "default" : null,
    "aliases" : [ "department_name" ], <- old columns here
    "columnName" : "department_name",
    "sqlType" : "12"
  } ],
  "tableName" : "departments"
Old column names or "aliases" should go inside of the aliases array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With