@classmethod
    def from_message(cls, query_id, column_metadata, pk_indexes, cluster_metadata, query, prepared_keyspace, protocol_version):
        if not column_metadata:
            return PreparedStatement(column_metadata, query_id, None, query, prepared_keyspace, protocol_version)

        if pk_indexes:
            routing_key_indexes = pk_indexes
        else:
            routing_key_indexes = None

            first_col = column_metadata[0]
            ks_meta = cluster_metadata.keyspaces.get(first_col.keyspace_name)
            if ks_meta:
                table_meta = ks_meta.tables.get(first_col.table_name)
                if table_meta:
                    partition_key_columns = table_meta.partition_key

                    # make a map of {column_name: index} for each column in the statement
                    statement_indexes = dict((c.name, i) for i, c in enumerate(column_metadata))

                    # a list of which indexes in the statement correspond to partition key items
                    try:
                        routing_key_indexes = [statement_indexes[c.name]
                                               for c in partition_key_columns]
                    except __HOLE__:  # we're missing a partition key component in the prepared
                        pass          # statement; just leave routing_key_indexes as None

        return PreparedStatement(column_metadata, query_id, routing_key_indexes,
                                 query, prepared_keyspace, protocol_version)
dataset/ETHPy150Open datastax/python-driver/cassandra/query.py/PreparedStatement.from_message