ComposantsComponents › TraitementProcessing
Sort d'une colonne Dynamic des colonnes nommées et typées. Une colonne Dynamic porte des colonnes connues seulement à l'exécution : celles de l'en-tête d'un fichier, du résultat d'une requête. Le tExtractDynamicFields en tire celles dont le job a besoin, par leur nom, et les convertit dans le type du schéma ; le reste peut suivre dans une colonne Dynamic de sortie. Après lui, le flux est ordinaire : tous les composants l'acceptent. L'inverse est le tWriteDynamicFields. Takes named and typed columns out of a Dynamic column. A Dynamic column carries columns only known at run time: those of the header of a file, of the result of a query. The tExtractDynamicFields takes out those the job needs, by their name, and converts them to the type of the schema; the rest can follow in a Dynamic output column. After it, the flow is an ordinary one: all components accept it. The reverse is the tWriteDynamicFields.
EntréeInput
Main un flux avec une colonne Dynamic (obligatoire)one flow with a Dynamic column (required)
SortieOutput
Main un flux : une ligne par ligne reçue, avec les colonnes du schémaone flow: one row per row received, with the columns of the schema
Déclencheurs en sortieOutput triggers
On Component Ok On Component Error Run if
Le fichier est lu avec une colonne Dynamic qui prend toutes ses colonnes, nommées par son en-tête. Le tExtractDynamicFields en sort name et city ; le tSortRow, qui n'accepte pas le type Dynamic, peut alors trier sur elles.
The file is read with a Dynamic column that takes all its columns, named by its header. The tExtractDynamicFields takes out name and city; the tSortRow, which does not accept the Dynamic type, can then sort on them.
Talend Open Studio n'avait pas le type Dynamic. Talaxie l'ajoute, avec ces deux composants. Une colonne Dynamic est un conteneur : pour chaque ligne, la liste des champs (nom, type, type en base, longueur…) et leurs valeurs. Avant de générer le code, Talaxie vérifie les schémas et s'arrête avec un message si une règle n'est pas tenue. Talend Open Studio did not have the Dynamic type. Talaxie adds it, with these two components. A Dynamic column is a container: for each row, the list of fields (name, type, database type, length…) and their values. Before generating the code, Talaxie checks the schemas and stops with a message if a rule is not met.
Essayés pour ces pages (Talaxie 9.0.6, Java 21) : tFileInputDelimited (colonnes nommées par l'en-tête), tLogRow (colonnes dépliées), tJavaRow, tFileOutputDelimited (en-tête et valeurs dépliés), tMap (colonne transmise sans la renommer), tExtractDynamicFields, tWriteDynamicFields.
Tried for these pages (Talaxie 9.0.6, Java 21): tFileInputDelimited (columns named by the header), tLogRow (columns unfolded), tJavaRow, tFileOutputDelimited (header and values unfolded), tMap (column passed on without renaming it), tExtractDynamicFields, tWriteDynamicFields.
Acceptés aussi par Talaxie, non essayés ici : tFilterRow, tFilterColumns, tReplicate, tBufferOutput, tHashInput, tHashOutput, tRunJob (sans processus indépendant ni job dynamique) ; tMysqlInput, tOracleInput, tPostgresqlInput, tMSSqlInput et leurs Output, sans connexion existante et avec des restrictions de réglages. Le tFileInputDelimited ne l'accepte pas avec Utiliser dynamique existant, le tFileOutputDelimited ni en Sortie en mode ligne, ni parallélisé. Also accepted by Talaxie, not tried here: tFilterRow, tFilterColumns, tReplicate, tBufferOutput, tHashInput, tHashOutput, tRunJob (without independent process nor dynamic job); tMysqlInput, tOracleInput, tPostgresqlInput, tMSSqlInput and their Output, without existing connection and with restrictions on settings. The tFileInputDelimited does not accept it with Use existing dynamic, nor the tFileOutputDelimited in Output in row mode or parallelized.
Les autres composants refusent un schéma Dynamic. Un tSortRow derrière un tFileInputDelimited dynamique, par exemple, arrête la génération : tSortRow_1 : Ce composant ne supporte pas le type Dynamique. C'est ce qui rend utile le tExtractDynamicFields : sans colonne Dynamic en sortie, son flux passe partout.
The other components refuse a Dynamic schema. A tSortRow after a dynamic tFileInputDelimited, for example, stops the generation: tSortRow_1 : Ce composant ne supporte pas le type Dynamique. This is what makes the tExtractDynamicFields useful: without a Dynamic output column, its flow goes everywhere.
Le composant n'a qu'un paramètre, son schéma ; le libellé est le même en français et en anglais. Il n'a pas de paramètres avancés. The component has only one setting, its schema; the label is the same in French and in English. It has no advanced settings.
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| SchemaSCHEMA | videempty | ToujoursAlways |
Les colonnes de sortie. Chacune est prise, dans l'ordre :
The output columns. Each one is taken, in this order:
|
null dans une colonne numérique, Boolean, Character ou Date ; il reste vide dans une colonne String.An empty text gives null in a numeric, Boolean, Character or Date column; it stays empty in a String column.Missing value for required id_Integer field, Empty value for required id_Integer field.In a non-nullable column, a missing or empty field stops the job: Missing value for required id_Integer field, Empty value for required id_Integer field.NumberFormatException).A text that does not convert stops the job (NumberFormatException)."yyyy-MM-dd") : sans lui, A date pattern is required. Une valeur déjà de type Date est reprise telle quelle.A date read from a text needs the pattern of the column, read strictly ("yyyy-MM-dd"): without it, A date pattern is required. A value already of type Date is taken as it is.NB_LINE (Integer, disponible après l'exécution du composant) : nombre de lignes traitées. NB_LINE (Integer, available after the component has run): number of rows processed.
((Integer) globalMap.get("tExtractDynamicFields_1_NB_LINE"))
Le composant n'a pas de lien Reject : une erreur de conversion arrête le job. The component has no Reject link: a conversion error stops the job.
Un tFileInputDelimited lit C:\data\people.csv (séparateur ;, une ligne d'en-tête) avec le schéma id (Integer), fields (Dynamic). Les sorties sont copiées depuis des exécutions des jobs dans Talaxie (Java 21).
A tFileInputDelimited reads C:\data\people.csv (; separator, one header line) with the schema id (Integer), fields (Dynamic). The outputs are copied from runs of the jobs in Talaxie (Java 21).
id;name;city;age;since 1;Ada;London;36;2020-01-15 2;Alan;;41; 3;Grace;New York;;2019-07-01
Un tJavaRow liste les champs de fields, puis un tLogRow en tableau affiche les lignes :
A tJavaRow lists the fields of fields, then a tLogRow as a table prints the rows:
routines.system.Dynamic dyn = input_row.fields;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < dyn.getColumnCount(); i++) {
routines.system.DynamicMetadata m = dyn.getColumnMetadata(i);
Object v = dyn.getColumnValue(i);
sb.append(i == 0 ? "" : ", ").append(m.getName()).append(" (").append(m.getType()).append(", ").append(v == null ? "null" : v.getClass().getSimpleName()).append(")=").append(v);
}
System.out.println("fields: " + sb);
output_row.id = input_row.id;
output_row.fields = input_row.fields;
fields: name (id_String, String)=Ada, city (id_String, String)=London, age (id_String, String)=36, since (id_String, String)=2020-01-15 fields: name (id_String, String)=Alan, city (id_String, String)=, age (id_String, String)=41, since (id_String, String)= fields: name (id_String, String)=Grace, city (id_String, String)=New York, age (id_String, String)=, since (id_String, String)=2019-07-01 tLogRow_1 +----+-------+----------+-----+------------+ | id | name | city | age | since | +----+-------+----------+-----+------------+ | 1 | Ada | London | 36 | 2020-01-15 | | 2 | Alan | | 41 | | | 3 | Grace | New York | | 2019-07-01 | +----+-------+----------+-----+------------+
Lus d'un fichier, tous les champs sont des textes ; une case vide est un texte vide. id, déclaré dans le schéma, n'est pas dans le Dynamic.
Read from a file, all the fields are texts; an empty cell is an empty text. id, declared in the schema, is not in the Dynamic.
Schéma : id (Integer), name (String), age (Integer), since (Date, motif "yyyy-MM-dd"), country (String), rest (Dynamic). Un tJava affiche NB_LINE.
Schema: id (Integer), name (String), age (Integer), since (Date, pattern "yyyy-MM-dd"), country (String), rest (Dynamic). A tJava prints NB_LINE.
tLogRow_1 +----+-------+------+------------+---------+----------+ | id | name | age | since | country | city | +----+-------+------+------------+---------+----------+ | 1 | Ada | 36 | 2020-01-15 | null | London | | 2 | Alan | 41 | null | null | | | 3 | Grace | null | 2019-07-01 | null | New York | +----+-------+------+------------+---------+----------+ tExtractDynamicFields_1_NB_LINE: 3
age et since sont convertis ; un texte vide y donne null. country, absent du fichier, vaut null sans erreur. Le Dynamic rest ne contient plus que city, qui reste un texte (vide pour Alan).
age and since are converted; an empty text gives null there. country, missing from the file, is null without error. The rest Dynamic only holds city, which stays a text (empty for Alan).
Schéma id, city, NAME : le nom en majuscules ne correspond à aucun champ.
Schema id, city, NAME: the upper-case name matches no field.
.--+--------+----. | tLogRow_1 | |=-+--------+---=| |id|city |NAME| |=-+--------+---=| |1 |London |null| |2 | |null| |3 |New York|null| '--+--------+----'
Schéma id, name, city, suivi d'un tSortRow sur name, alphabétique, décroissant :
Schema id, name, city, followed by a tSortRow on name, alphabetical, descending:
.--+-----+--------. | tLogRow_1 | |=-+-----+-------=| |id|name |city | |=-+-----+-------=| |3 |Grace|New York| |2 |Alan | | |1 |Ada |London | '--+-----+--------'
Sans colonne Dynamic, le tLogRow revient à son tableau habituel, et le tSortRow accepte le flux. Without a Dynamic column, the tLogRow goes back to its usual table, and the tSortRow accepts the flow.
Un tWriteDynamicFields range name, city, age (Integer) et since (Date) dans fields ; le tExtractDynamicFields en reprend age (Integer) et since (Date, motif "dd/MM/yyyy"), et garde fields :
A tWriteDynamicFields puts name, city, age (Integer) and since (Date) in fields; the tExtractDynamicFields takes back age (Integer) and since (Date, pattern "dd/MM/yyyy"), and keeps fields:
tLogRow_1 +----+-----+------------+------+--------+ | id | age | since | name | city | +----+-----+------------+------+--------+ | 1 | 36 | 15/01/2020 | Ada | London | | 2 | 41 | null | Alan | null | +----+-----+------------+------+--------+
Les valeurs gardent leur type Java : la date n'est pas relue d'un texte, le motif de la colonne ne sert qu'à l'affichage du tLogRow. Values keep their Java type: the date is not read from a text, the pattern of the column only serves the display of the tLogRow.
Même fichier. Le nom du job est remplacé par MyJob et les traces d'exception sont abrégées ; chaque erreur d'exécution donne le code de sortie 1.
Same file. The job name is replaced with MyJob and exception traces are shortened; each run-time error gives exit code 1.
Schéma id, age (Integer, non nullable), tLogRow en mode simple. La troisième ligne n'a pas d'âge :
Schema id, age (Integer, not nullable), tLogRow in basic mode. The third row has no age:
1|36 2|41 Exception in component tExtractDynamicFields_1 (MyJob) java.lang.IllegalArgumentException: Empty value for required id_Integer field at routines.system.DynamicFields.convert(DynamicFields.java:50) …
Colonne since (Date) sans motif :
since column (Date) without pattern:
Exception in component tExtractDynamicFields_1 (MyJob) java.lang.IllegalArgumentException: A date pattern is required at routines.system.DynamicFields.convert(DynamicFields.java:69) …
Colonne city déclarée Integer :
city column declared Integer:
Exception in component tExtractDynamicFields_1 (MyJob) java.lang.NumberFormatException: For input string: "London" at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) … at routines.system.DynamicFields.convert(DynamicFields.java:56) …
Un tFixedFlowInput (id, name, city) relié au tExtractDynamicFields : la génération s'arrête, le job ne démarre pas. Ce message n'existe qu'en anglais.
A tFixedFlowInput (id, name, city) connected to the tExtractDynamicFields: the generation stops, the job does not start. This message only exists in English.
tExtractDynamicFields_1 : tExtractDynamicFields requires a Dynamic input column.
Un champ se trouve par son nom exact : NAME ne trouve pas name, et un nom mal écrit donne null sans message. Si une colonne est indispensable, rendez-la non nullable : son absence arrêtera le job au lieu de passer inaperçue.
A field is found by its exact name: NAME does not find name, and a misspelt name gives null without message. If a column is essential, make it not nullable: its absence will stop the job instead of going unnoticed.
Une valeur qui ne se convertit pas arrête le job. Pour écarter les lignes douteuses, extrayez les champs en String, puis convertissez-les avec un tConvertType, qui a un lien Reject. A value that does not convert stops the job. To set aside doubtful rows, extract the fields as String, then convert them with a tConvertType, which has a Reject link.
tWriteDynamicFields · regrouper des colonnes dans une colonne Dynamicpack columns into a Dynamic columntFileInputDelimited · lire un fichier dont les colonnes viennent de l'en-têteread a file whose columns come from the headertJavaRow · parcourir les champs d'un Dynamic en Javago through the fields of a Dynamic in JavatConvertType · convertir des colonnes, avec rejetsconvert columns, with rejectstFilterColumns · garder certaines colonnes d'un fluxkeep some columns of a flowtLogRow · afficher les lignes, colonnes dynamiques comprisesdisplay the rows, dynamic columns included