def incremental_export_into_outfile metadata
      unless @export_obj.is_running?
        
        if @export_obj.export_type == "incremental"
          max_value = @export_obj.max_value
          metadata.export_type = "incremental"        
          @export_obj.update_max_val if @export_obj.max_incremental_value.blank?   
        end
        if (@export_obj.export_type == "all" && @export_obj.export_to == "vertica")
          metadata.export_type = "incremental"
        end

        options = {
          :db => @export_obj.source_schema,
          :source_schema => @export_obj.source_schema,
          :table => @export_obj.table_name,
          :filepath => filepath,
          :destination_schema => @export_obj.destination_schema,
          :enclosed_by => Myreplicator.configs[@export_obj.source_schema]["enclosed_by"],
          :export_id => @export_obj.id
        }

        schema_status = Myreplicator::MysqlExporter.schema_changed?(options)
        Kernel.p "===== schema_status ====="
        Kernel.p schema_status
        if schema_status[:changed] # && new?
          metadata.export_type = "initial"
        else
          options[:incremental_col] = @export_obj.incremental_column
          options[:incremental_col_type] = @export_obj.incremental_column_type
          options[:export_type] = @export_obj.export_type
          options[:incremental_val] = [@export_obj.destination_max_incremental_value, @export_obj.max_incremental_value].min
          #options[:incremental_val] = @export_obj.max_incremental_value
        end

        #Kernel.p "===== incremental_export_into_outfile OPTIONS ====="
        #Kernel.p options
        cmd = SqlCommands.mysql_export_outfile(options)
        #Kernel.p "===== incremental_export_into_outfile CMD ====="
        #puts cmd      
        exporting_state_trans
        puts "Exporting..."
        result = execute_export(cmd, metadata)
        check_result(result, 0)

        if @export_obj.export_type == "incremental"
          metadata.incremental_val = max_value # store max val in metadata
          @export_obj.update_max_val(max_value) # update max value if export was successful
        end
      end

      return false
    end
def incremental_export_into_outfile metadata
      unless @export_obj.is_running?
        
        if @export_obj.export_type == "incremental"
          max_value = @export_obj.max_value
          metadata.export_type = "incremental"        
          @export_obj.update_max_val if @export_obj.max_incremental_value.blank?   
        end
        if (@export_obj.export_type == "all" && @export_obj.export_to == "vertica")
          metadata.export_type = "incremental"
        end

        options = {
          :db => @export_obj.source_schema,
          :source_schema => @export_obj.source_schema,
          :table => @export_obj.table_name,
          :filepath => filepath,
          :destination_schema => @export_obj.destination_schema,
          :enclosed_by => Myreplicator.configs[@export_obj.source_schema]["enclosed_by"],
          :export_id => @export_obj.id
        }

        schema_status = Myreplicator::MysqlExporter.schema_changed?(options)
        Kernel.p "===== schema_status ====="
        Kernel.p schema_status
        if schema_status[:changed] # && new?
          metadata.export_type = "initial"
        else
          options[:incremental_col] = @export_obj.incremental_column
          options[:incremental_col_type] = @export_obj.incremental_column_type
          options[:export_type] = @export_obj.export_type
          options[:incremental_val] = [@export_obj.destination_max_incremental_value, @export_obj.max_incremental_value].min
          #options[:incremental_val] = @export_obj.max_incremental_value
        end

        #Kernel.p "===== incremental_export_into_outfile OPTIONS ====="
        #Kernel.p options
        cmd = SqlCommands.mysql_export_outfile(options)
        #Kernel.p "===== incremental_export_into_outfile CMD ====="
        #puts cmd      
        exporting_state_trans
        puts "Exporting..."
        result = execute_export(cmd, metadata)
        check_result(result, 0)

        if @export_obj.export_type == "incremental"
          metadata.incremental_val = max_value # store max val in metadata
          @export_obj.update_max_val(max_value) # update max value if export was successful
        end
      end

      return false
    end
Exports table incrementally, similar to incremental_export method
 Dumps file in tmp directory specified in myreplicator.yml
 Note that directory needs 777 permissions for mysql to be able to export the file
 Uses \\0 as the delimiter and new line for lines