Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for constants on empty lists, fixes #2102 #2762

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@

package org.apache.hop.core.injection.bean;

import org.apache.hop.core.RowMetaAndData;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.injection.AfterInjection;
import org.apache.hop.metadata.api.IHopMetadata;
import org.apache.hop.metadata.api.IHopMetadataProvider;
import org.apache.hop.metadata.api.IHopMetadataSerializer;
import static com.google.common.collect.Lists.newLinkedList;
import static java.util.Objects.requireNonNull;

import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
Expand All @@ -34,9 +30,12 @@
import java.util.Optional;
import java.util.Queue;
import java.util.stream.Collectors;

import static com.google.common.collect.Lists.newLinkedList;
import static java.util.Objects.requireNonNull;
import org.apache.hop.core.RowMetaAndData;
import org.apache.hop.core.exception.HopException;
import org.apache.hop.core.injection.AfterInjection;
import org.apache.hop.metadata.api.IHopMetadata;
import org.apache.hop.metadata.api.IHopMetadataProvider;
import org.apache.hop.metadata.api.IHopMetadataSerializer;

/** Engine for get/set metadata injection properties from bean. */
public class BeanInjector<Meta extends Object> {
Expand Down Expand Up @@ -443,6 +442,10 @@ private List<Object> checkList(BeanLevelInfo s, Object obj, int index) throws Ex
if (existList == null) {
return null;
}
// if constants are added without data we still want 1 row created
if (existList.size() == 0) {
return extendList(s, obj, 1);
}

return index < existList.size() ? existList : null;
}
Expand Down
49 changes: 24 additions & 25 deletions integration-tests/mdi/0025-get-variables-parent.hpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ limitations under the License.
<extended_description/>
<pipeline_version/>
<pipeline_type>Normal</pipeline_type>
<pipeline_status>0</pipeline_status>
<parameters>
</parameters>
<capture_transform_performance>N</capture_transform_performance>
Expand All @@ -34,8 +35,6 @@ limitations under the License.
<created_date>2022/12/05 22:54:39.724</created_date>
<modified_user>-</modified_user>
<modified_date>2022/12/05 22:54:39.724</modified_date>
<key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA=</key_for_session_key>
<is_key_private>N</is_key_private>
</info>
<notepads>
</notepads>
Expand Down Expand Up @@ -147,46 +146,46 @@ limitations under the License.
<method>none</method>
<schema_name/>
</partitioning>
<data>
<line>
<item>A</item>
<item>${A}</item>
<item>String</item>
</line>
<line>
<item>B</item>
<item>${B}</item>
<item>String</item>
</line>
<line>
<item>C</item>
<item>${C}</item>
<item>String</item>
</line>
</data>
<fields>
<field>
<set_empty_string>N</set_empty_string>
<length>-1</length>
<name>name</name>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>name</name>
<type>String</type>
</field>
<field>
<set_empty_string>N</set_empty_string>
<length>-1</length>
<name>variable</name>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>variable</name>
<type>String</type>
</field>
<field>
<set_empty_string>N</set_empty_string>
<length>-1</length>
<name>type</name>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>type</name>
<type>String</type>
</field>
</fields>
<data>
<line>
<item>A</item>
<item>${A}</item>
<item>2</item>
</line>
<line>
<item>B</item>
<item>${B}</item>
<item>2</item>
</line>
<line>
<item>C</item>
<item>${C}</item>
<item>2</item>
</line>
</data>
<attributes/>
<GUI>
<xloc>128</xloc>
Expand Down
123 changes: 123 additions & 0 deletions integration-tests/mdi/0026-inject-using-constants-only-child.hpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<pipeline>
<info>
<name>0026-inject-using-constants-only-child</name>
<name_sync_with_filename>Y</name_sync_with_filename>
<description/>
<extended_description/>
<pipeline_version/>
<pipeline_type>Normal</pipeline_type>
<parameters>
</parameters>
<capture_transform_performance>N</capture_transform_performance>
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
<created_user>-</created_user>
<created_date>2022/03/23 12:29:35.111</created_date>
<modified_user>-</modified_user>
<modified_date>2022/03/23 12:29:35.111</modified_date>
</info>
<notepads>
</notepads>
<order>
<hop>
<from>Data grid</from>
<to>Row denormaliser</to>
<enabled>Y</enabled>
</hop>
</order>
<transform>
<name>Data grid</name>
<type>DataGrid</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<data>
<line>
<item>A</item>
<item>A</item>
<item>100</item>
</line>
<line>
<item>A</item>
<item>A</item>
<item>20</item>
</line>
</data>
<fields>
<field>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>group</name>
<type>String</type>
</field>
<field>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>key</name>
<type>String</type>
</field>
<field>
<length>-1</length>
<precision>-1</precision>
<set_empty_string>N</set_empty_string>
<name>value</name>
<type>Number</type>
</field>
</fields>
<attributes/>
<GUI>
<xloc>96</xloc>
<yloc>64</yloc>
</GUI>
</transform>
<transform>
<name>Row denormaliser</name>
<type>Denormaliser</type>
<description/>
<distribute>Y</distribute>
<custom_distribution/>
<copies>1</copies>
<partitioning>
<method>none</method>
<schema_name/>
</partitioning>
<fields>
</fields>
<group>
</group>
<attributes/>
<GUI>
<xloc>240</xloc>
<yloc>64</yloc>
</GUI>
</transform>
<transform_error_handling>
</transform_error_handling>
<attributes/>
</pipeline>
Loading