You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ar_order.rb
    path of file: ./repos/manageiq/lib/extensions
    
    the code of the file until where you have to start completion: # This monkey patches rails to support proper joins
# current PR: https://github.com/rails/rails/pull/36531
module ActiveRecord
  module ConnectionAdapters
    module PostgreSQL
      module SchemaStatements
        def columns_for_distinct(columns, orders) # :nodoc:
          order_columns = orders.reject(&:blank?).map do |s|
              # Convert Arel node to string
         
    
        def columns_for_distinct(columns, orders) # :nodoc:
          order_columns = orders.reject(&:blank?).map do |s|
              # Convert Arel node to string
              unless s.is_a?(String)
                if s.kind_of?(Arel::Nodes::Ordering)
                  s = s.expr
                  keep_order = true
                end
                if s.respond_to?(:to_sql)
                  s = s.to_sql
                else # for Arel::Nodes::Attribute
                  engine = Arel::Table.engine
                  collector = Arel::Collectors::SQLString.new
                  collector = engine.connection.visitor.accept s, collector
                  s = collector.value
                end