Column Schema in External table definition

Amandeep Bajaj 26 Reputation points
2023-11-01T07:06:11.5+00:00

Hi Team,

Recently I have observed two things on Azure Synapse serverless, which I'd like to highlight here one by one:

  1. Issue in External File Format: I have observed in the syntax of creating an external file format we do not have the option of Header_Row=True option, why is that?
  2. Column Order in External Table: Can I not give any custom/random column order while defining the external table in Synapse serverless? Does the column names need to be in the specific order as in the file in order to create an external table.
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,375 questions
Developer technologies | Transact-SQL
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2023-11-01T07:06:11.53+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    For your first question, the option HEADER_ROW is not available in the syntax of creating an external file format in Azure Synapse serverless SQL pools.

    Regarding your second question, the column names in the external table definition do not need to be in the same order as the columns in the file. You can specify the column order in the CREATE EXTERNAL TABLE statement using the COLUMN_ORDINAL option.

    Here's an example of how to create an external table with custom column order:

    CREATE EXTERNAL TABLE MyExternalTable (
        Column3 int,
        Column1 varchar(100),
        Column2 varchar(50)
    )
    WITH (
        LOCATION = 'my/location',
        DATA_SOURCE = MyDataSource,
        FILE_FORMAT = MyFileFormat,
        REJECT_TYPE = VALUE,
        REJECT_VALUE = 0,
        COLUMN_ORDINAL = 'Column3, Column1, Column2'
    );
    

    In the example above, the columns in the external table are defined in a different order than the columns in the file. The COLUMN_ORDINAL option is used to specify the order of the columns in the file.


    References:

    0 comments No comments

  2. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2023-11-01T10:46:59.85+00:00

    Hi Amandeep Bajaj,

    Thank you for posting query in Microsoft Q&A Platform.

    You are right, HEADER_ROW = True option will not be available in File Format. While we create External Tables, we will define the Headers and in File Format Option we can define First_Row option. Hence, Having HEADER_ROW is not needed.

    You can give column order differently as well. It should work.

    Hope this helps. Please let me know if any further queries.


    Please consider hitting Accept Answer button. Accepted answers help community as well. Thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.