How do I write query results to LUSID with the writer designer?

Prev Next

Once a query returns the right rows, loading them into LUSID is one more step. Writer providers such as Lusid.Portfolio.Txn.Writer and Lusid.Instrument.Equity.Writer create, update and delete data, and the writer designer in the Luminesce Query Editor matches your query's columns to the writer's fields for you, so you can load a file of trades or a set of instruments without writing the mapping by hand.

Writes change real data

Running the generated query writes to LUSID straight away. Check the query, and try it on a few rows first.

Prerequisites

  • Access to the Luminesce Query Editor in the LUSID web app, under Data Virtualisation > Query Editor.

  • Permission to use the writer provider, and to change the data it writes. See Query Editor permissions reference.

  • A query that returns the rows you want to write, for example one that reads a file with the file designer.

Methods

Method 1: Write a query's results

  1. Put the query in the editor, then select the writer designer on the toolbar. You can also select Writer Designer in the query designer or the file designer.

  2. In Selected writer, choose the writer, such as Lusid.Portfolio.Txn.Writer. The list holds every writer you have permission to use.

  3. The table lists each of the writer's fields under Writer field. Hover over a field's information icon for its description. Wherever one of your columns has the same name as a field, ignoring case, spaces, underscores and hyphens, the designer has already mapped it in Map.

  4. Map the rest. For each field, choose one of your columns in Map, or type an expression, such as 'Upsert' for a WriteAction field or upper(Currency). To build a longer expression, select the row and use the editor beside the table; Easy Case helps you write a case expression. Leave a field empty to leave it out of the write.

  5. Select Generate SQL.

The designer changes your query so that it:

  • Returns one column per mapped field, named after the field, for example TradeDate as [TransactionDate].

  • Puts those rows in a table variable, @write, if they aren't in one already.

  • Ends with select * from [Lusid.Portfolio.Txn.Writer] where [ToWrite] = @write;, which does the writing.

Run the query. The writer returns a row for each row it wrote; check its WriteErrorCode and WriteError columns for any that failed.

Method 2: Let Candela choose the writer and mapping

Select Writer Designer assistant. Candela suggests the writer best suited to your data and a mapping for its fields. Apply its mapping from its reply, then check every field before you generate the SQL. To go back to the designer's own matching, select Reset to defaults.

Candela availability

Candela is currently available to some customers only. If it isn't available in your domain, you don't see Writer Designer assistant.

Method 3: Change an existing write

Open the writer designer on a query that already writes, such as one it generated. Change the writer or the mapping and select Generate SQL. The designer replaces the existing write rather than adding a second one.

Troubleshooting

Generate SQL is greyed out

Choose a writer in Selected writer.

The writer returns errors for some rows

Read WriteError on those rows. Common causes are a required field left unmapped, a value of the wrong type, or a missing WriteAction. To see which fields a writer needs, see its page under Providers.

A writer isn't in the list

You don't have permission to use it. Ask your LUSID administrator.