code: def test_construct_query_string_with_duplicated_records(
      sagemaker_session_mock, feature_group_mock
  ):
      dataset_builder = DatasetBuilder(
          sagemaker_session=sagemaker_session_mock,
          base=feature_group_mock,
          output_path="file/to/path",
      )
      dataset_builder._include_duplicated_records = True
  
      dataset_builder._feature_groups_to_be_merged = [FEATURE_GROUP]
      query_string = dataset_builder._construct_query_string(BASE)
      assert (
          query_string
          == "WITH fg_base AS (WITH deleted_base AS (\n"
          + "SELECT *\n"
          + "FROM (\n"
          + "SELECT *, row_number() OVER (\n"
          + 'PARTITION BY origin_base."target-feature"\n'
          + 'ORDER BY origin_base."other-feature" DESC, origin_base."api_invocation_time" DESC, '
          + 'origin_base."write_time" DESC\n'
          + ") AS deleted_row_base\n"
          + 'FROM "database"."base-table" origin_base\n'
          + "WHERE is_deleted\n"
          + ")\n"
          + "WHERE deleted_row_base = 1\n"
          + ")\n"
          + 'SELECT table_base."target-feature", table_base."other-feature"\n'
          + "FROM (\n"
          + 'SELECT table_base."target-feature", table_base."other-feature", '
          + 'table_base."write_time"\n'
          + 'FROM "database"."base-table" table_base\n'
          + "LEFT JOIN deleted_base\n"
          + 'ON table_base."target-feature" = deleted_base."target-feature"\n'
          + 'WHERE deleted_base."target-feature" IS NULL\n'
          + "UNION ALL\n"
          + 'SELECT table_base."target-feature", table_base."other-feature", '
          + 'table_base."write_time"\n'
          + "FROM deleted_base\n"
          + 'JOIN "database"."base-table" table_base\n'
          + 'ON table_base."target-feature" = deleted_base."target-feature"\n'
          + "AND (\n"
          + 'table_base."other-feature" > deleted_base."other-feature"\n'
          + 'OR (table_base."other-feature" = deleted_base."other-feature" AND '
          + 'table_base."api_invocation_time" > deleted_base."api_invocation_time")\n'
          + 'OR (table_base."other-feature" = deleted_base."other-feature" AND '
          + 'table_base."api_invocation_time" = deleted_base."api_invocation_time" AND '
          + 'table_base."write_time" > deleted_base."write_time")\n'
          + ")\n"
          + ") AS table_base\n"
          + "),\n"
          + "fg_0 AS (WITH deleted_0 AS (\n"
          + "SELECT *\n"
          + "FROM (\n"
          + "SELECT *, row_number() OVER (\n"
          + 'PARTITION BY origin_0."feature-1"\n'
          + 'ORDER BY origin_0."feature-2" DESC, origin_0."api_invocation_time" DESC, '
          + 'origin_0."write_time" DESC\n'
          + ") AS deleted_row_0\n"
          + 'FROM "database"."table-name" origin_0\n'
          + "WHERE is_deleted\n"
          + ")\n"
          + "WHERE deleted_row_0 = 1\n"
          + ")\n"
          + 'SELECT table_0."feature-1", table_0."feature-2"\n'
          + "FROM (\n"
          + 'SELECT table_0."feature-1", table_0."feature-2", table_0."write_time"\n'
          + 'FROM "database"."table-name" table_0\n'
          + "LEFT JOIN deleted_0\n"
          + 'ON table_0."feature-1" = deleted_0."feature-1"\n'
          + 'WHERE deleted_0."feature-1" IS NULL\n'
          + "UNION ALL\n"
          + 'SELECT table_0."feature-1", table_0."feature-2", table_0."write_time"\n'
          + "FROM deleted_0\n"
          + 'JOIN "database"."table-name" table_0\n'
          + 'ON table_0."feature-1" = deleted_0."feature-1"\n'
          + "AND (\n"
          + 'table_0."feature-2" > deleted_0."feature-2"\n'
          + 'OR (table_0."feature-2" = deleted_0."feature-2" AND table_0."api_invocation_time" > '
          + 'deleted_0."api_invocation_time")\n'
          + 'OR (table_0."feature-2" = deleted_0."feature-2" AND table_0."api_invocation_time" = '
          + 'deleted_0."api_invocation_time" AND table_0."write_time" > deleted_0."write_time")\n'
          + ")\n"
          + ") AS table_0\n"
          + ")\n"
          + 'SELECT target-feature, other-feature, "feature-1.1", "feature-2.1"\n'
          + "FROM (\n"
          + 'SELECT fg_base.target-feature, fg_base.other-feature, fg_0."feature-1" as '
          + '"feature-1.1", fg_0."feature-2" as "feature-2.1", row_number() OVER (\n'
          + 'PARTITION BY fg_base."target-feature"\n'
          + 'ORDER BY fg_base."other-feature" DESC, fg_0."feature-2" DESC\n'
          + ") AS row_recent\n"
          + "FROM fg_base\n"
          + "JOIN fg_0\n"
          + 'ON fg_base."target-feature" = fg_0."feature-1"\n'
          + ")\n"
      )
  
imports: from __future__ import absolute_import
  import datetime
  import pandas
  import pytest
  import os
  from mock import Mock, patch
  from sagemaker.feature_store.dataset_builder import DatasetBuilder, FeatureGroupToBeMerged, TableType, JoinComparatorEnum, JoinTypeEnum
  from sagemaker.feature_store.feature_group import FeatureDefinition, FeatureGroup, FeatureTypeEnum
label_desc: Use image node_id 19 for calling a global function with example usage: test_construct_query_string_with_duplicated_records(sagemaker_session_mock, feature_group_mock) without return types